0

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.

Alvaro
  • 40,778
  • 30
  • 164
  • 336

2 Answers2

1

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?

Belvasis
  • 238
  • 1
  • 9
1

...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.

Pareshkumar
  • 176
  • 6
  • Yeah it was a mistake, i have added the idMovie on the session table. So... no need for it at reservation right? Thanks. – Alvaro Jul 20 '12 at 16:01
  • No it doesnt look like you have to deep of a decency so quick query will get you what you need. And not adding movieID to reservation leaves the table open to have other types of reservations in the future. Live shows, a lemo or table for dinner. Not that you will need it but a reservation for a session keeps it abstracted. – Pareshkumar Jul 20 '12 at 16:39