Reputation: 41605
I have this tables: movie, session (a movie displayed at a datetime) and User.
Users can make reservations for a movie at a concrete session. Drawing it i have it like:
movie **1** ----- **n** sesion
|
**n**
User
I was thinking creating the tables like this:
Movie(id, title, minutes) Sesion(id, idMovie, datetime) User(id, name) Reservation(idSesion, idUser, numTickets)
Would it be ok? or should i include also idMovie at my reservation table?
Thanks.
Upvotes: 0
Views: 80
Reputation: 176
...a movie displayed at a datetime... But if you were trying to get a list date time when a movie is in session how could you get to that? I don't think you need movieID in the reserv table but you may want to have a movieID in the session table.
Then you can get to the movie from knowing the user or find all users attending a movie or session. Adding movie Id in the reservation would be duplicate reference and extra thing to keep synced you don't need because it's treversable by other foreign key relationship.
Upvotes: 1
Reputation: 238
You don't need a idMovie at your reservation table but at your session table. How does a session know to what movie it belongs?
Upvotes: 1