Food delivery app ERD
Customer, store, menu, order and rider. An order points to all three; the rider can be empty until assigned, hence zero or one.
The diagram
Reading it step by step
- 'Customer' has 2 attributes, primary key customer_id.
- 'Store' has 2 attributes, primary key store_id.
- 'MenuItem' has 4 attributes, primary key menu_id, foreign key store_id.
- 'Orders' has 4 attributes, primary key order_id, foreign key customer_id, store_id, rider_id.
- 'Rider' has 2 attributes, primary key rider_id.
- Each 'Store' relates to one or more 'MenuItem'; each 'MenuItem' to exactly one 'Store' (sells).
- Each 'Customer' relates to zero or more 'Orders'; each 'Orders' to exactly one 'Customer' (places).
- Each 'Store' relates to zero or more 'Orders'; each 'Orders' to exactly one 'Store' (receives).
- Each 'Rider' relates to zero or more 'Orders'; each 'Orders' to zero or one 'Rider' (delivers).
Shape by shape
| Shape | Symbol | Connections |
|---|---|---|
| Customer | Entity | holds customer_id, address · → Orders(places) |
| Store | Entity | holds store_id, store_name · → MenuItem(sells), Orders(receives) |
| MenuItem | Entity | holds menu_id, store_id, item_name, price · ← Store |
| Orders | Entity | holds order_id, customer_id, store_id, rider_id · ← Customer, Store, Rider |
| Rider | Entity | holds rider_id, vehicle · → Orders(delivers) |
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.
# Food delivery app ERD
erDiagram
Customer {
int customer_id PK
varchar address
}
Store {
int store_id PK
varchar store_name
}
MenuItem {
int menu_id PK
int store_id FK
varchar item_name
int price
}
Orders {
int order_id PK
int customer_id FK
int store_id FK
int rider_id FK
}
Rider {
int rider_id PK
varchar vehicle
}
Store ||--|{ MenuItem : sells
Customer ||--o{ Orders : places
Store ||--o{ Orders : receives
Rider |o--o{ Orders : delivers