title: Online restaurant reservation system (data structures)
body: <p>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)</p>
  
  <p>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.</p>
  
  <p>I'm having trouble coming up with the right data structures to use.</p>
  
  <p>My classes are as follows</p>
  
  <p><strong>Restaurant</strong> : 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.</p>
  
  <p><strong>Reservation</strong>: This maintains the actual reservation and allows to cancel reservation</p>
  
  <p><strong>ReservationSystem</strong> : 
  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.</p>
  
  <p>My specific questions are:</p>
  
  <ol>
  <li>How do i store the table information within each restaurant.</li>
  <li>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.</li>
  </ol>
  
  <p>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) </p>
  
  <p>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. </p>