Knowledge Guide
HomeDatabasesNormalization

Designing a Hotel Management System

In this case study, we'll explore the database modeling of a Hotel Management System using Entity-Relationship (ER) design and then map it to a relational database schema. By following this guide, you'll gain a comprehensive understanding of how to model databases for complex systems like hotels.

Requirements Analysis

Understanding the system's requirements is the first and most crucial step. It ensures that the database will support all necessary functionalities.

For our case study, let's outline the key functionalities that the HMS should support:

Step-by-Step ER Diagram Creation

We will build the ER diagram for the Hospital Management System through the following four steps.

Step 1: Identify Entities

Entities represent objects or concepts in the system that have data stored about them.

Primary Entities

  1. Guest
  2. Room
  3. Reservation
  4. Payment
  5. Staff
  6. Service
  7. Room_Type
  8. Department
Entities for the Hotel Management System
Entities for the Hotel Management System

Step 2: Detailing Attributes

We'll define attributes for each entity, including primary keys (PK) and foreign keys (FK).

1. Guest

2. Room

3. Room_Type

4. Reservation

6. Payment

7. Staff

8. Department

9. Service

Attributes for the Entities of Hotel Management System
Attributes for the Entities of Hotel Management System

Step 3: Defining Relationships

1. Guest and Reservation

2. Reservation and Room

3. Room and Room_Type

4. Guest and Service

5. Payment and Reservation

6. Room and Department

7. Staff and Department

Here is the final ER diagram.

ER Diagram for Hotel Management System
ER Diagram for Hotel Management System

Mapping the ER Diagram to a Relational Schema

When converting the ER diagram into a relational schema for our Hotel Management System, we need to carefully handle various components to ensure data integrity and optimal performance. Here are the key considerations:

Here is the final relational schema diagram.

Relational Schema Diagram for the Hotel Management System
Relational Schema Diagram for the Hotel Management System

Now, let's translate the ER model into SQL tables.

1. Guest Table

CREATE TABLE Guest ( Guest_ID INT PRIMARY KEY, First_Name VARCHAR(50), Last_Name VARCHAR(50), Date_of_Birth DATE, Gender VARCHAR(10), Address VARCHAR(100), Email VARCHAR(50), Identification_Type VARCHAR(20), Identification_Number VARCHAR(50) );

2. Guest_Phone_Number Table

CREATE TABLE Guest_Phone_Number ( Guest_ID INT, Phone_Number VARCHAR(15), PRIMARY KEY (Guest_ID, Phone_Number), FOREIGN KEY (Guest_ID) REFERENCES Guest(Guest_ID) );

3. Room_Type Table

CREATE TABLE Room_Type ( Room_Type_ID INT PRIMARY KEY, Type_Name VARCHAR(20), Description TEXT, Price_Per_Night DECIMAL(10, 2), Max_Occupancy INT );

4. Room Table

CREATE TABLE Room ( Room_ID INT PRIMARY KEY, Room_Number VARCHAR(10), Floor INT, Status VARCHAR(20), -- e.g., Available, Occupied, Maintenance Room_Type_ID INT, Department_ID INT, FOREIGN KEY (Room_Type_ID) REFERENCES Room_Type(Room_Type_ID), FOREIGN KEY (Department_ID) REFERENCES Department(Department_ID) );

5. Reservation Table

CREATE TABLE Reservation ( Reservation_ID INT PRIMARY KEY, Check_In_Date DATE, Check_Out_Date DATE, Number_of_Guests INT, Reservation_Status VARCHAR(20), -- e.g., Booked, Checked-In, Checked-Out, Cancelled Guest_ID INT, FOREIGN KEY (Guest_ID) REFERENCES Guest(Guest_ID) );

6. Reservation_Room Table

CREATE TABLE Reservation_Room ( Reservation_ID INT, Room_ID INT, Rate_Applied DECIMAL(10, 2), Notes TEXT, PRIMARY KEY (Reservation_ID, Room_ID), FOREIGN KEY (Reservation_ID) REFERENCES Reservation(Reservation_ID), FOREIGN KEY (Room_ID) REFERENCES Room(Room_ID) );

7. Payment Table

CREATE TABLE Payment ( Payment_ID INT PRIMARY KEY, Payment_Date DATE, Amount DECIMAL(10, 2), Payment_Method VARCHAR(20), -- e.g., Credit Card, Cash Reservation_ID INT, FOREIGN KEY (Reservation_ID) REFERENCES Reservation(Reservation_ID) );

8. Staff Table

CREATE TABLE Staff ( Staff_ID INT PRIMARY KEY, First_Name VARCHAR(50), Last_Name VARCHAR(50), Role VARCHAR(50), Email VARCHAR(50), Department_ID INT, FOREIGN KEY (Department_ID) REFERENCES Department(Department_ID) );

9. Staff_Phone_Number Table

CREATE TABLE Staff_Phone_Number ( Staff_ID INT, Phone_Number VARCHAR(15), PRIMARY KEY (Staff_ID, Phone_Number), FOREIGN KEY (Staff_ID) REFERENCES Staff(Staff_ID) );

10. Department Table

CREATE TABLE Department ( Department_ID INT PRIMARY KEY, Department_Name VARCHAR(50), Description TEXT );

11. Service Table

CREATE TABLE Service ( Service_ID INT PRIMARY KEY, Service_Name VARCHAR(50), Description TEXT, Price DECIMAL(10, 2) );

12. Guest_Service Table

CREATE TABLE Guest_Service ( Guest_ID INT, Service_ID INT, Reservation_ID INT, Quantity INT, Total_Cost DECIMAL(10, 2), PRIMARY KEY (Guest_ID, Service_ID, Reservation_ID), FOREIGN KEY (Guest_ID) REFERENCES Guest(Guest_ID), FOREIGN KEY (Service_ID) REFERENCES Service(Service_ID), FOREIGN KEY (Reservation_ID) REFERENCES Reservation(Reservation_ID) );
🤖 Don't fully get this? Learn it with Claude

Stuck on Designing a Hotel Management System? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Designing a Hotel Management System** (Databases) and want to truly understand it. Explain Designing a Hotel Management System from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Designing a Hotel Management System** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Designing a Hotel Management System** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Designing a Hotel Management System** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes