Diagram Desk

Hotel reservation ERD

Guest, room, room type and reservation. Price sits on the room type, not on every room: a small normalisation lesson.

The diagram

GuestPK guest_id intname varcharRoomTypePK type_id inttype_name varcharnightly_rate intRoomPK room_no intFK type_id intfloor intReservationPK reservation_id intFK guest_id intFK room_no intcheck_in datecheck_out dateclassifiesmakesassigned_to
ER diagram · 17 shapes

Reading it step by step

  • 'Guest' has 2 attributes, primary key guest_id.
  • 'RoomType' has 3 attributes, primary key type_id.
  • 'Room' has 3 attributes, primary key room_no, foreign key type_id.
  • 'Reservation' has 5 attributes, primary key reservation_id, foreign key guest_id, room_no.
  • Each 'RoomType' relates to one or more 'Room'; each 'Room' to exactly one 'RoomType' (classifies).
  • Each 'Guest' relates to zero or more 'Reservation'; each 'Reservation' to exactly one 'Guest' (makes).
  • Each 'Room' relates to zero or more 'Reservation'; each 'Reservation' to exactly one 'Room' (assigned_to).

Shape by shape

ShapeSymbolConnections
GuestEntityholds guest_id, name · → Reservation(makes)
RoomTypeEntityholds type_id, type_name, nightly_rate · → Room(classifies)
RoomEntityholds room_no, type_id, floor · → Reservation(assigned_to) · ← RoomType
ReservationEntityholds reservation_id, guest_id, room_no, check_in, check_out · ← Guest, Room

Symbols used here

SymbolMeaning
EntityA thing to store: name on top, attributes below.
Primary key (PK)The attribute that identifies one row; underlined.
Foreign key (FK)An attribute pointing to another entity's key.
Exactly oneTwo short bars at the line end.
Zero or manyA crow's foot and a circle.
One or manyA crow's foot and a bar.

All er diagram symbols and how to draw

Diagram text

Paste this text into the editor to get the same picture, then change the names to fit your own work.

# Hotel reservation ERD
erDiagram
  Guest {
    int guest_id PK
    varchar name
  }
  RoomType {
    int type_id PK
    varchar type_name
    int nightly_rate
  }
  Room {
    int room_no PK
    int type_id FK
    int floor
  }
  Reservation {
    int reservation_id PK
    int guest_id FK
    int room_no FK
    date check_in
    date check_out
  }
  RoomType ||--|{ Room : classifies
  Guest ||--o{ Reservation : makes
  Room ||--o{ Reservation : assigned_to

More er diagram examples

All SeewolLabs tools