Middle+
How can free seats for a specific session be determined using the current scheme? Is a separate booking entity needed?
sobes.tech AI
Answer from AI
To determine available seats for a specific session, you need data on all seats and information on which ones are already occupied. If the current schema includes an entity "Session" and an entity "Seat" (for example, a chair in the hall), then to track occupancy, these seats must be linked to reservations or ticket sales.
A separate reservation entity is needed if it is required to record the reservation before payment or to manage statuses (reserved, paid, canceled). Such an entity will allow:
- Tracking which seats are occupied or reserved.
- Managing the reservation process (for example, temporarily holding a seat).
- Ensuring data integrity and avoiding double booking.
An example of a simplified structure:
- Session (id, date, time, hall)
- Seat (id, number, hall)
- Reservation (id, session_id, seat_id, status)
To find available seats for a session, select all seats in the hall and exclude those that are in reservations with an active status for that session.