← Questions
Design a restaurant reservation service
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Design the object model for a restaurant reservation service. Restaurants have tables of different sizes and open hours divided into time slots. Guests search for availability by party size and time, book, change and cancel reservations. A table must never be booked twice for overlapping times.
Requirements
- Functional: search a restaurant's free slots for a date, time and party size; book a slot, which holds a table that fits the party; modify a reservation (time or party size) or cancel it; restaurants configure tables, hours and how long a seating lasts; staff mark guests as seated or no-show.
- Large parties can use combined tables if the restaurant allows it.
- Non-functional: no double booking, even when two guests book the last table at the same moment; search is fast for a day's slots.
Clarifying questions
- Is it one restaurant or a platform with many?
- How long is a seating, and is it fixed or by party size?
- Does the guest choose a table, or does the system assign one?
- Can tables be combined for large parties?
- Are deposits, cancellation fees or waitlists in scope?
What a strong answer covers
- Core classes:
Restaurant(tables, opening hours, seating rules),Table(ID, capacity, combinable),TimeSlot,Reservation(guest, party size, start, end, table or tables, status),Guest, and aReservationServicefor search, book, modify and cancel, with aTableAssignmentStrategy. - Availability as interval overlap per table: a reservation occupies
[start, start + duration), and a table is free if no confirmed reservation overlaps. - Choosing the smallest table that fits so large tables stay free for large parties.
- Preventing double booking: lock per table (or per restaurant) during booking, or a database constraint on overlapping intervals; a modification as an atomic swap that keeps the old booking if the new time is not free.
- Reservation states (booked, seated, completed, cancelled, no-show) and their transitions.
- Tests: back-to-back bookings, a party too large for any table, modifying into a taken slot.
Follow-ups
- Add a waitlist that offers freed slots to waiting guests.
- Add deposits for large parties and a no-show fee.
- Let walk-ins take tables without breaking upcoming reservations.
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.
What the labs asked this week
A weekly email of what OpenAI, Anthropic and the other top AI labs asked engineers, round by round.
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing
