Reply To: RE: How to persist seat availability data
Hi,
You are welcome.
The described requirement can be achieved with the given model. If you find a reservation for the seat and the scheduled movie (that defines the movie and its show time), the seat is not available.
You can also modify the model so that the Reservation entity will include the IsAvailable flag and after scheduling a movie, the reservations (records) will be initialized for all seats with IsAvailable set to True.
In the original model, if this query returns a row the seat is taken. Otherwise, for an empty result, the seat is free.
SELECT * FROM Reservation
INNER JOIN Seat ON Seat.ID = Reservation.SeatID
WHERE
Seat.Number = <ChosenSeat>
AND Reservation.MovieID = <ChosenMovieAtShowTime>
You can also join the ScheduledMovie entity if you want to select the movie by its time. If you want to select the data also by movie name, you can also join the Movie entity.
Dusan Rodina - softwareideas.net
13 May 2021 17:21:47
Reply To: RE: How to persist seat availability data
Hi,
You are welcome.
The described requirement can be achieved with the given model. If you find a reservation for the seat and the scheduled movie (that defines the movie and its show time), the seat is not available.
You can also modify the model so that the Reservation entity will include the IsAvailable flag and after scheduling a movie, the reservations (records) will be initialized for all seats with IsAvailable set to True.
In the original model, if this query returns a row the seat is taken. Otherwise, for an empty result, the seat is free.
SELECT * FROM Reservation
INNER JOIN Seat ON Seat.ID = Reservation.SeatID
WHERE
Seat.Number = <ChosenSeat>
AND Reservation.MovieID = <ChosenMovieAtShowTime>
You can also join the ScheduledMovie entity if you want to select the movie by its time. If you want to select the data also by movie name, you can also join the Movie entity.
Dusan Rodina - softwareideas.net 13 May 2021 17:21:47