advancedTop 15 Database Design Questions
Design a hotel room booking system that prevents double-bookings.
rooms(id, number, type, price_per_night) bookings(id, room_id FK, guest_id FK, stay_period DATERANGE NOT NULL, total_price, status) EXCLUDE constraint: EXCLUDE USING GIST (room_id WITH =, stay_period WITH &&) WHERE status != 'CANCELLED' GiST index automatically created by EXCLUDE constraint Partial index on active bookings: WHERE status IN ('CONFIRMED', 'PENDING') The EXCLUDE constraint prevents o
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
Design a hotel room booking system that prevents double-bookings.