Database Design:
Hotel Booking
A guide for a database design for a sample hotel
booking system
Ben Brumm
www.databasestar.com
Database Design: Hotel Booking
This guide is a companion to my YouTube video on designing a database for a hotel booking system.
In this guide, you'll see:
● An Entity Relationship Diagram for a hotel booking system, from my YouTube video.
● An explanation of the purpose of each table and field, with sample data
● SQL scripts to create each of these tables with some sample data
Let's get into it.
Entity Relationship Diagram
Here's the ERD for this database:
A PNG file of this ERD is available here:
https://dbshostedfiles.s3.us-west-2.amazonaws.com/dbs/erd_hotel.png
Database Design - Hotel Booking
Database Definition
This section explains each of these tables and fields.
guest
A guest is a person who stays at the hotel and the one who makes the booking.
Column Description Sample Data
id Primary key. A unique identifier for the 1, 2, 3
row.
first_name The first name of the guest John
Sandip
Stephanie
last_name The last name of the guest Kumar
Smith
Jones
email_address The email address for the guest, which can [email protected]
be used to send booking details to and to
log in.
phone_number The phone number for the guest which can 0139029321
be used to contact them.
booking
A record of a guest making a booking to stay in the hotel. This is created when the guest makes the
booking, which can be some time before the date the guest stays in the hotel (the check in date).
Column Description Sample Data
id Primary key. A unique identifier for the 1, 2, 3
row.
guest_id The foreign key to the guest table, which 1, 5, 6
indicates the guest that the booking is for.
payment_status_id The foreign key to the payment_status 1, 2
table, which indicate the status of the
www.DatabaseStar.com 2
Database Design - Hotel Booking
booking
checkin_date The date that the guest is checking in to 30 Sep 2023
their room.
checkout_date The date that the guest is checking out of 4 Oct 2023
their room.
num_adults The number of adults included in the 2
booking. Multiple adults may lead to
booking multiple rooms.
num_children The number of children included in the 2
booking.
booking_amount The amount the guest needs to pay for 810.00
their booking.
payment_status
A lookup table for the different payment statuses for a booking.
Column Description Sample Data
id Primary key. A unique identifier for 1, 2, 3
the row.
payment_status_name A name for the payment status which Paid
can be understood by guests and Pending
other users. Not Paid
addon
A lookup table for the different things that a guest can pay for in their booking.
Column Description Sample Data
id Primary key. A unique identifier for the 1, 2, 3
row.
addon_name The name of the addon that is understood Valet Parking
by the guest Late Checkout
www.DatabaseStar.com 3
Database Design - Hotel Booking
Minibar - Small Alcohol
price The price the guest needs to pay for the 20
addon 50
8
booking_addon
A record of all of the addons that the customer adds to their booking.
Column Description Sample Data
booking_id A foreign key to the booking table, to 1, 2, 3
indicate which booking this record relates
to.
addon_id A foreign key to the addon table, to indicate 1, 2, 3
which addon this record relates to.
booking_room
A record of rooms for a booking, because a room can be booked many times, and a booking can include
multiple rooms.
Column Description Sample Data
booking_id A foreign key to the booking table, to 1, 2, 3
indicate which booking this record relates to.
room_id A foreign key to the room table, to indicate 1, 2, 3
which room this record relates to.
room
A representation of a hotel room that guests can stay in and that guests can book.
Column Description Sample Data
www.DatabaseStar.com 4
Database Design - Hotel Booking
id Primary key. A unique identifier for the 1, 2, 3
row.
floor_id A foreign key to the floor table, to indicate 1, 5, 6
which floor this room is on.
room_class_id A foreign key to the room_class table, to 2, 4, 5
indicate the class of this room
status_id A foreign key to the status table, to 1, 3, 4
indicate the status of the room.
room_number The number of the room that may be 502, 1001
shown near the door and written on the
swipe card
floor
A lookup table for the floor that a room exists on.
Column Description Sample Data
id Primary key. A unique identifier for the 1, 2, 3
row.
floor_number The number of the floor that is known by 1, 4, 5A, 5B
the staff and guests.
room_status
A lookup table to contain the different statuses of a room's lifecycle.
Column Description Sample Data
id Primary key. A unique identifier for the row. 1, 2, 3
status_name The name of the step in the lifecycle Occupied, Ready to Clean,
Available
www.DatabaseStar.com 5
Database Design - Hotel Booking
room_class
A lookup table that defines the different classes of a room.
Column Description Sample Data
id Primary key. A unique identifier for the 1, 2, 3
row.
class_name The name of the class, and is familiar to Deluxe, Standard, Premium,
staff and guests. Presidential
base_price The price for a room of this class 100, 350, 1200
bed_type
A lookup table for the different types of beds that are available for rooms.
Column Description Sample Data
id Primary key. A unique identifier for the 1, 2, 3
row.
bed_type_name The type of bed that can exist in a room. Single, Double, Queen, King
room_class_bed_type
A record of the number and type of beds that exist in a particular room, because a room can have
different types of beds.
Column Description Sample Data
room_class_id A foreign key to the room_class table, to 1, 3, 6
indicate which room class the record belongs
to.
bed_type_id A foreign key to the bed_type table, to indicate 1, 2, 4
which type of bed the record belongs to
num_beds The number of beds of this type in this room 1, 2
www.DatabaseStar.com 6
Database Design - Hotel Booking
feature
A lookup table for all of the features available in a room.
Column Description Sample Data
id Primary key. A unique identifier for the 1, 2, 3
row.
feature_name The name of the feature that the guests Coffee Machine
know it as Air Conditioning
Free Wifi
room_class_feature
A record of the features available in a particular room.
Column Description Sample Data
room_class_id A foreign key for the room_class table, to 1, 2, 4
indicate the class of room for this record.
feature_id A foreign key for the feature table, to 2, 3, 7
indicate the feature for this record.
www.DatabaseStar.com 7
Database Design - Hotel Booking
SQL Scripts
Here is the SQL code to create the tables for this database.
The script is written for MySQL, but it can easily be modified to work on your preferred database
vendor by changing the data types and removing the IF EXISTS (if your database doesn't support it).
CREATE DATABASE hotel_booking;
USE hotel_booking;
DROP TABLE IF EXISTS booking_room;
DROP TABLE IF EXISTS room;
DROP TABLE IF EXISTS floor;
DROP TABLE IF EXISTS room_status;
DROP TABLE IF EXISTS room_class_bed_type;
DROP TABLE IF EXISTS room_class_feature;
DROP TABLE IF EXISTS feature;
DROP TABLE IF EXISTS room_class;
DROP TABLE IF EXISTS bed_type;
DROP TABLE IF EXISTS booking_addon;
DROP TABLE IF EXISTS addon;
DROP TABLE IF EXISTS booking;
DROP TABLE IF EXISTS payment_status;
DROP TABLE IF EXISTS guest;
CREATE TABLE guest (
id INT AUTO_INCREMENT,
first_name VARCHAR(200),
last_name VARCHAR(200),
email_address VARCHAR(350),
phone_number VARCHAR(20),
CONSTRAINT pk_guest PRIMARY KEY (id)
);
CREATE TABLE payment_status (
id INT AUTO_INCREMENT,
payment_status_name VARCHAR(50),
CONSTRAINT pk_paystatus PRIMARY KEY (id)
);
CREATE TABLE booking (
id INT AUTO_INCREMENT,
guest_id INT,
payment_status_id INT,
checkin_date DATE,
www.DatabaseStar.com 8
Database Design - Hotel Booking
checkout_date DATE,
num_adults INT,
num_children INT,
booking_amount INT,
CONSTRAINT pk_booking PRIMARY KEY (id),
CONSTRAINT fk_booking_guest FOREIGN KEY (guest_id) REFERENCES guest
(id),
CONSTRAINT fk_booking_paystatus FOREIGN KEY (payment_status_id)
REFERENCES payment_status (id)
);
CREATE TABLE addon (
id INT AUTO_INCREMENT,
addon_name VARCHAR(100),
price INT,
CONSTRAINT pk_addon PRIMARY KEY (id)
);
CREATE TABLE booking_addon (
booking_id INT,
addon_id INT,
CONSTRAINT fk_bkaddon_booking FOREIGN KEY (booking_id) REFERENCES
booking (id),
CONSTRAINT fk_bkaddon_addon FOREIGN KEY (addon_id) REFERENCES addon
(id)
);
CREATE TABLE bed_type (
id INT AUTO_INCREMENT,
bed_type_name VARCHAR(50),
CONSTRAINT pk_bedtype PRIMARY KEY (id)
);
CREATE TABLE room_class (
id INT AUTO_INCREMENT,
class_name VARCHAR(100),
base_price INT,
CONSTRAINT pk_addon PRIMARY KEY (id)
);
CREATE TABLE feature (
id INT AUTO_INCREMENT,
feature_name VARCHAR(100),
CONSTRAINT pk_addon PRIMARY KEY (id)
);
CREATE TABLE room_class_feature (
room_class_id INT,
www.DatabaseStar.com 9
Database Design - Hotel Booking
feature_id INT,
CONSTRAINT fk_rmclsft_roomclass FOREIGN KEY (room_class_id) REFERENCES
room_class (id),
CONSTRAINT fk_rmclsft_feature FOREIGN KEY (feature_id) REFERENCES
feature (id)
);
CREATE TABLE room_class_bed_type (
id INT AUTO_INCREMENT,
room_class_id INT,
bed_type_id INT,
num_beds INT,
CONSTRAINT pk_room_class_bed_type PRIMARY KEY (id),
CONSTRAINT fk_room_class_bed_type_room_class FOREIGN KEY
(room_class_id) REFERENCES room_class (id),
CONSTRAINT fk_room_class_bed_type_bed_type FOREIGN KEY (bed_type_id)
REFERENCES bed_type (id)
);
CREATE TABLE room_status (
id INT AUTO_INCREMENT,
status_name VARCHAR(100),
CONSTRAINT pk_addon PRIMARY KEY (id)
);
CREATE TABLE floor (
id INT AUTO_INCREMENT,
floor_number VARCHAR(5),
CONSTRAINT pk_addon PRIMARY KEY (id)
);
CREATE TABLE room (
id INT AUTO_INCREMENT,
floor_id INT,
room_class_id INT,
status_id INT,
room_number VARCHAR(10),
CONSTRAINT pk_addon PRIMARY KEY (id),
CONSTRAINT fk_room_floor FOREIGN KEY (floor_id) REFERENCES floor (id),
CONSTRAINT fk_room_roomclass FOREIGN KEY (room_class_id) REFERENCES
room_class (id),
CONSTRAINT fk_room_status FOREIGN KEY (status_id) REFERENCES
room_status (id)
);
CREATE TABLE booking_room (
booking_id INT,
room_id INT,
www.DatabaseStar.com 10
Database Design - Hotel Booking
CONSTRAINT fk_bkroom_booking FOREIGN KEY (booking_id) REFERENCES
booking (id),
CONSTRAINT fk_bkroom_room FOREIGN KEY (room_id) REFERENCES room (id)
);
Conclusion
I hope you found this guide useful. If you have any questions or issues with it, let me know at
[email protected].
Thanks,
Ben Brumm
www.DatabaseStar.com
www.DatabaseStar.com 11