Reply To: RE: How to persist seat availability data


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


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 - 13 May 2021 17:21:47

New Comment

You can use these formatting tags: [b]bold[/b] [i]italic[/i] [u]underline[/u] [url][/url] [code]some code[/code] [quote]quoted text[/quote] [list]one list item per line[/list]