Answer the question
In order to leave comments, you need to log in
Laravel pivot or model when linking three tables, which is better to use?
The question is which is better to use.
For example, let's take a movie database:
table movie (movies)
id
name
table person (people - actors, screenwriters, operators and others)
id
name
table role (role - actor, screenwriter, make-up artist)
id
name
How best to link them to determine the role. For example, in a film, the actor and screenwriter may be the same person.
Alternatively pivot:
movie_id, role_id, person_id
You can create a separate model like PersonRole:
id, role_id, person_id
and pivot: movie_id, person_role_id
Which would be better? Or is it implemented in some other way? Interested from the point of building architecture.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question