Cafe POS ERD
Menu, order, order line and payment for a cafe till. One order has at most one payment, so a one-to-zero-or-one mark appears next to the usual crow's feet.
The diagram
Reading it step by step
- 'Menu' has 3 attributes, primary key menu_id.
- 'Orders' has 2 attributes, primary key order_id.
- 'OrderLine' has 4 attributes, primary key line_id, foreign key order_id, menu_id.
- 'Payment' has 3 attributes, primary key payment_id, foreign key order_id.
- Each 'Orders' relates to one or more 'OrderLine'; each 'OrderLine' to exactly one 'Orders' (contains).
- Each 'Menu' relates to zero or more 'OrderLine'; each 'OrderLine' to exactly one 'Menu' (ordered_as).
- Each 'Orders' relates to zero or one 'Payment'; each 'Payment' to exactly one 'Orders' (paid_by).
Shape by shape
| Shape | Symbol | Connections |
|---|---|---|
| Menu | Entity | holds menu_id, menu_name, price · → OrderLine(ordered_as) |
| Orders | Entity | holds order_id, ordered_at · → OrderLine(contains), Payment(paid_by) |
| OrderLine | Entity | holds line_id, order_id, menu_id, quantity · ← Orders, Menu |
| Payment | Entity | holds payment_id, order_id, method · ← Orders |
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 one | A bar and a circle. |
| 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.
# Cafe POS ERD
erDiagram
Menu {
int menu_id PK
varchar menu_name
int price
}
Orders {
int order_id PK
datetime ordered_at
}
OrderLine {
int line_id PK
int order_id FK
int menu_id FK
int quantity
}
Payment {
int payment_id PK
int order_id FK
varchar method
}
Orders ||--|{ OrderLine : contains
Menu ||--o{ OrderLine : ordered_as
Orders ||--o| Payment : paid_by