The Fake Geek's blog: Design Hotel Reservation
Room
Customer
http://www.vertabelo.com/blog/technical-articles/designing-a-data-model-for-a-hotel-room-booking-system
ReservationSystem ==> FacadeDesign a hotel reservation system. To make it simple, we assume that the hotel has only one building and the building has only one floor. Design your objects so that they work better with a non-sql database, say a document-oriented database.
Room
Customer
http://www.vertabelo.com/blog/technical-articles/designing-a-data-model-for-a-hotel-room-booking-system
Database modeling is a cyclic discovery process. We first identify the main tables and its attributes. In our model, the main tables are:
room
, guest
and reservation
. Then we continue refining our tables by discovering their attributes or columns. For example, the room
table has attributes like: room number
,name
and smoke
flag among others.Reservation
table has attributes date_in
, date_out
, status
(canceled, confirmed) andmade_by
(online, in_person, phone, mail), while the attributes of the table guest
are: first_name
,last_name
and member_since
. Perhaps you feel like the reservation
table needs more attributes (like room type, number of beds), we will cover this point later, until then, consider ourreservation
table incomplete.Data Types: What Are the Domains of Allowed Values for a Column?
Continue Discovering; Find New Database Objects
A reservation is one of the more complex elements to represent in this data model. One reservation can have many rooms associated with it (for example “I wish to make a reservation for one double room and a separate room with 3 beds for my kids”). This business requirement adds 4 things to our model:
A new table: We need to create a new table called
room_reserved
, where we store all rooms belonging to one reservation.
Add two references: A reference is a very important element in a data model. A reference describes how one table is related to another table. In our model, every room reserved belongs to one reservation, so we will use a reference to model that fact. This reference is graphically represented as a line connecting both tables.
Moreover, as every reservation belongs to one guest, we need to create a new reference linking the
guest
and the reservation
tables.
Move a column: Since we can have several rooms belonging to one reservation, we must allow cancelation per individual room, after that we move the
attribute
status from reservation
toreserved_room
table.- If two or more guests are sharing a room, allow different check-in and check-out for each guest.
- In some cases hotels can change the configuration of the rooms (for example from standard one double bed to luxury 2 double beds). Add to the data model the elements to represent those configuration changes, maintaining the history of every room.
- Search.
- Results.
- Booking Validation.