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
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
| Shape | Symbol | Connections |
|---|---|---|
| Guest | Entity | holds guest_id, name · → Reservation(makes) |
| RoomType | Entity | holds type_id, type_name, nightly_rate · → Room(classifies) |
| Room | Entity | holds room_no, type_id, floor · → Reservation(assigned_to) · ← RoomType |
| Reservation | Entity | holds reservation_id, guest_id, room_no, check_in, check_out · ← Guest, Room |
Symbols used here
| Symbol | Meaning |
|---|---|
| Entity | A 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 one | Two short bars at the line end. |
| Zero or many | A crow's foot and a circle. |
| One or many | A crow's foot and a bar. |
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