Flights and Passengers tables on flight_id to align passenger bookings with flight capacities.flight_id and count the number of passengers for each flight using the COUNT() function.booked_cnt) by taking the minimum of the flight's capacity and the passenger count.waitlist_cnt) by subtracting the confirmed bookings from the total passenger count and ensuring the result is not negative using the GREATEST() function.flight_id in ascending order.erDiagram
Flights {
int flight_id PK
int capacity
}
Passengers {
int passenger_id PK
int flight_id FK
}
Flights ||--o{ Passengers : contains