Consider a system with three classes: Hotel, Room, and Booking. Which of the following best describes their relationship?
Think about real-life hotels: one hotel has many rooms, and rooms can be booked multiple times.
Hotels have many rooms. Each room can be booked many times, so bookings relate to rooms, not hotels directly.
Which Booking class design best prevents double booking of the same Room for overlapping dates?
To avoid double booking, you must track both the room and the booking dates.
Booking must include roomId and date range to check for overlaps and prevent double booking.
What is the best approach to scale the Booking system to handle millions of bookings across thousands of hotels?
Think about how to distribute load and speed up queries for large data.
Sharding by hotelId distributes data and caching room availability reduces database hits, improving scalability.
In a distributed Booking system, what is the main tradeoff when choosing between strong consistency and high availability?
Consider what happens if parts of the system cannot communicate.
Strong consistency ensures no conflicting bookings but may reject requests during network issues, lowering availability.
Which sequence correctly describes the interaction flow when a user books a room?
Think about the logical order of actions from user input to confirmation.
User selects room first, system checks availability, then creates booking, and finally confirms.