Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Online restaurant reservation system (data structures)

I have a task to design an online reservation system. Where a user can enter zip code/ no of people/time of reservation and get a list of restaurants. Assumption (User and restaurant are always in the same city)

Each restaurant can have multiple tables with different number of seats. So, 2 tables that seat 4 people and 4 tables that seat 4 people.

I'm having trouble coming up with the right data structures to use.

My classes are as follows

Restaurant : Contains timeofopening, timeOfClosing, totalNoOfSeatsAvailable Not sure how i will store table information within the restaurant. It doesn't make sense to have a separate class for the table. All the info i need is howManytables are free and what are their sizes.

Reservation: This maintains the actual reservation and allows to cancel reservation

ReservationSystem : contains the interface to `List checkAvailability(long time, int people)' How will this return this list? I initially thought of using a priorityQueue to maintain a queue with max no of seats available. But then i will go through that list to see if the time is correct to even make the reservation and then once a reservation is made,update this queue. One problem is the queue does all duplicates.

My specific questions are:

  1. How do i store the table information within each restaurant.
  2. What is the best way to maintain this list of restaurants so i can give return a list without having to sort this information everytime.

EDIT: For the question on how to store the table information. My specific concern is that storing a table class would mean that i'm creating un necessary objects. Here's my reasoning. 5 tables that seat 2 people each with have the exact same objects - i mean there isn't any meaningful information that will be differnet among them. I just need to numbers. no of seats/table.(If i have a table of 4 but 3 peole, I will consider this table taken)

I thought of creating 3 arrays. Lets say table represent 1,2 etc so int[] differentSeatingOnTable; its indexes are tables and values are seats allowed. Next an array of tables with totalNoOfThosetable where indexs are tables and values are total number of such table. Similary for free tables freeTables where index are table and how many of such free table are left.

like image 849
12rad Avatar asked Aug 17 '13 16:08

12rad


People also ask

What is an online reservation system for restaurants?

A restaurant reservation system lets customers reserve a table while restaurateurs oversee bookings, cancellations, and no-shows. Reservation software may also offer waitlist tools, visual table management features or allow you to handle digital pre-payments.

How does a restaurant reservation system work?

Online reservation platforms like Resy and OpenTable do the work for you — guests simply go online to reserve a table, and they can cancel or modify their reservation at any time. Most platforms can add reservation times to guests' calendars, log their reservation history, and even send reminders!

What kind of reservation do most restaurants use?

OpenTable. OpenTable is probably the most popular reservation system currently on the market, and for good reason. This platform is intuitively designed and easy to use for customers and restaurants. It sends automatic confirmation texts and emails.

How table reservation operates in the restaurants?

Restaurant reservations are an arrangement guests make in advance to confirm a table for their party at a specified time. Making a reservation at a restaurant can be done by phone, through a restaurant's website, third-party reservation sites or apps, at the restaurant in person, or even with a text message.


1 Answers

1. ) If you just store the amount of seats in a restaurant, you're shooting yourself in the foot. Suppose I need to make a reservation for 16 people, and they all must be on the same table (yes, I need a pretty long table). Your system could take my guests to someplace where they'd have to sit in 8 tables for two people each.

You do need a table class. Then your restaurants need to have collections of tables. If you want to know how many seats you have in a restaurant, you just have to iterate through its table collection and count the seats. And if you want to know if you can sit a family in a single table in a restaurant, you just have to check whether it has any table with that amount of seats.

EDIT: there is a more minimalistic way to store seats per restaurant. Use a dictionary, hash table or any other structure that holds keys and associated values. So have the key represent a type of table. The key may be an integer saying how many people the table sits. The value is the amount of tables of that type present in the restaurant. I think this is way better than my original suggestion.

So, for example, a restaurant with such a hash table:

Key | Value
 4  |   5
 2  |   8
16  |   1

Has five tables with 4 seats each, 8 tables with 2 seats each, and a single long table that sits 16 people. (Also using a table to store tables is so meta).

2. ) Your reasoning is right for the reservations. If it is doing duplicates, you should post a more especific question showing how you're doing it so we can try and help you locate the bug.

like image 154
Geeky Guy Avatar answered Oct 08 '22 19:10

Geeky Guy