I'm trying to create a three-way relationship with a pivot table.
What I have 4 models; Movie, People, PeopleRole, and MovieCast.
I currently have a DB schema like so:
movies_
-------------------
| id | name |
|----|------------|
| 1 | Fight Club |
| 2 | Inception |
movies_peoples
-------------------
| id | name |
|----|------------|
| 1 | Brad Pitt |
| 2 | Tom Cruise |
movies_peoples_roles
--------------------
| id | name |
|----|------------|
| 1 | Director |
| 2 | Writers |
movies_casts (pivot table)
--------------------------------------------------
| (pk) movie_id | (pk) role_id | (pk) people_id |
|---------------|--------------|-----------------|
| 1 | 1 | 1 |
| 1 | 1 | 2 |
| 1 | 2 | 1 |
| 2 | 1 | 2 |
Currently I have no idea how to do this. What is the best solution to implement this kind of relation?