ER Diagram for Hotel Management System
Guests book reservations for one or more rooms, rooms have a type that sets the nightly rate, stays generate charges and payments. Booking several rooms on one reservation is the rule most first drafts miss.
Why each relationship is drawn this way
- reservations ↔ roomsA family can book two rooms on one reservation and a room is booked many times, so reservation_rooms is a junction table that also freezes the rate agreed at booking time.
- room_type → roomsThe type sets capacity and the standard rate; rooms only store what is unique to them.
- reservation → charges / paymentsMinibar, room service and the room itself become charge rows; the folio balance is charges minus payments.
The schema
CREATE TABLE room_types ( id INT PRIMARY KEY, name VARCHAR(40) NOT NULL UNIQUE, max_guests INT NOT NULL, nightly_rate_cents INT NOT NULL ); CREATE TABLE rooms ( id INT PRIMARY KEY, room_type_id INT NOT NULL REFERENCES room_types(id), number VARCHAR(10) NOT NULL UNIQUE, floor INT NOT NULL ); CREATE TABLE guests ( id INT PRIMARY KEY, full_name VARCHAR(120) NOT NULL, email VARCHAR(255), phone VARCHAR(30) ); CREATE TABLE reservations ( id INT PRIMARY KEY, guest_id INT NOT NULL REFERENCES guests(id), check_in DATE NOT NULL, check_out DATE NOT NULL, status VARCHAR(20) NOT NULL, created_at TIMESTAMP NOT NULL ); CREATE TABLE reservation_rooms ( reservation_id INT NOT NULL, room_id INT NOT NULL, rate_cents INT NOT NULL, PRIMARY KEY (reservation_id, room_id), FOREIGN KEY (reservation_id) REFERENCES reservations(id), FOREIGN KEY (room_id) REFERENCES rooms(id) ); CREATE TABLE charges ( id INT PRIMARY KEY, reservation_id INT NOT NULL REFERENCES reservations(id), description VARCHAR(120) NOT NULL, amount_cents INT NOT NULL, charged_at TIMESTAMP NOT NULL ); CREATE TABLE payments ( id INT PRIMARY KEY, reservation_id INT NOT NULL REFERENCES reservations(id), amount_cents INT NOT NULL, method VARCHAR(20) NOT NULL, paid_at TIMESTAMP NOT NULL );
Design notes
- Availability for a date range: rooms with no reservation_rooms row whose reservation overlaps (check_in < :out AND check_out > :in).
- Copy the rate onto the booking: changing room_types later must not change past invoices.
Tables at a glance
room_types: id, name, max_guests, nightly_rate_centsrooms: id, room_type_id, number, floorguests: id, full_name, email, phonereservations: id, guest_id, check_in, check_out, status, created_atreservation_rooms: reservation_id, room_id, rate_centscharges: id, reservation_id, description, amount_cents, charged_atpayments: id, reservation_id, amount_cents, method, paid_at
Questions
What are the entities in a hotel management system ER diagram?
This design uses 7 tables: room_types, rooms, guests, reservations, reservation_rooms, charges, payments. A family can book two rooms on one reservation and a room is booked many times, so reservation_rooms is a junction table that also freezes the rate agreed at booking time.
How many relationships does the hotel management system ER diagram have?
6 foreign-key relationships. The many-to-many ones are resolved with junction tables, which is how they must be stored in a relational database.
Can I edit this ER diagram and export it?
Yes. “Edit in the ER diagram generator” opens the same SQL in the editor, where you can add tables, drag boxes and export SVG, PNG, Mermaid, DBML or SQL for PostgreSQL, MySQL, SQL Server or SQLite.
Which notation is used?
Crow’s foot: a fork means many, a bar means exactly one and a circle means optional (zero). A nullable foreign key gets the circle on the parent end.
More ER diagram examples
- Hospital Management SystemPatients are admitted to wards, seen by doctors who belong to departments, book appointments, receive prescriptions and are billed.
- Library Management SystemA library catalogues books (titles) and the physical copies on its shelves, lends copies to members, takes reservations and charges fines.
- Banking SystemCustomers hold accounts at branches (some accounts are joint), money moves through transactions, and customers take out loans.
- College Management SystemDepartments run courses, courses are offered as sections each term and taught by faculty, students enrol in sections and receive grades.
- Student Management SystemA school records students, their guardians, classes and subjects, daily attendance and exam marks.
- Online Shopping SystemAn e-commerce store: customers with saved addresses, products in categories, carts, orders with line items, payments and shipments.
- Employee Management SystemAn HR database: employees in departments, a manager hierarchy, job titles with salary history, projects staffed by several people, and leave requests.