I have a kinda unique situation here, I have 3 models: Degree
, Student
and Consultant
.
There is a many to many rel between a student and a consultant.
Also there is a many to many rel between degree and student.
I could have 2 pivot table for each one of those above relations,
BUT what important here is, is that: a student in a specific degree can have 1 consultant.
In other words creating 2 separate pivot table, doesn't give me the information which consultant is for what degree for a specific user.
I can think of 2 solutions here:
The first one is creating a pivot table with 3 foreign keys like:
student_id | degree_id | consultant_id
this way I could know who is the student's consultant for a specific degree.
But is this way, a standard way of architecturing database?
Also, Should I create a Pivot model for this?
What would be the code snippet look like?
The other approach I can think of is that create 2 separate pivot tables, and reference id
of one pivot table in the other one.
So this would look like something like:
degree_student: student_id | degree_id
consultant_student: student_id | consultant_id | **degree_student_id**
Again, is this a standard approach?
Should I create a Pivot model for this?
For final discussion, I would embrace any other solution suggestions that are better(/standard).
Note: I have checked here and here but couldn't satisfy my requirements.