- There are multiple Airlines
- Every Airline has multiple Flights
- Each Flight has 120 seats
- Each Flight has multiple Trips
- User can book a seat for available Trip
- Once seat is assigned to a passenger, the same seat can not be reassigned or transferred
- Multiple people should not be assigned to same seat
- Check-in should be as fast as possible
- When a passenger is booking a seat, it should not wait for other passengers bookings
- Ensure data is always in consistent state
- Ensure system is free of deadlocks
- Throughput should not be affected by db locking
postgres=# create user sanket with password 'sanket';
CREATE ROLE
postgres=# create database airline__checkin;
CREATE DATABASE
postgres=# grant all privileges on database airline__checkin to sanket;
GRANT
-
User
id | name | email | phone
-
Airline
id | name
-
Flight
id | name | airline_id
-
Trip
id | source | destination | starttime | flight_id
-
Seat
id | seat_number | seat_type | flight_id
-
Booking
id | booking_status | seat_id | trip_id | user_id
User (1 -> M) Booking
Airline (1 -> M) Flight
Flight (1 -> M) Trip
Flight (1 -> M) Seat
Trip (1 -> M) Booking
Seat (1 -> M) Booking
-
Arpit Bhayani's system design problem
https://github.com/arpitbbhayani/system-design-questions/blob/master/airline-checkin.md