Inventory ERD
Item, warehouse, stock and movement. Stock links items to warehouses; movements record every change.
The diagram
Reading it step by step
- 'Item' has 2 attributes, primary key item_code.
- 'Warehouse' has 2 attributes, primary key warehouse_id.
- 'Stock' has 4 attributes, primary key stock_id, foreign key item_code, warehouse_id.
- 'Movement' has 4 attributes, primary key movement_id, foreign key stock_id.
- Each 'Item' relates to zero or more 'Stock'; each 'Stock' to exactly one 'Item' (stored_as).
- Each 'Warehouse' relates to zero or more 'Stock'; each 'Stock' to exactly one 'Warehouse' (holds).
- Each 'Stock' relates to zero or more 'Movement'; each 'Movement' to exactly one 'Stock' (logged_in).
Shape by shape
| Shape | Symbol | Connections |
|---|---|---|
| Item | Entity | holds item_code, item_name · → Stock(stored_as) |
| Warehouse | Entity | holds warehouse_id, location · → Stock(holds) |
| Stock | Entity | holds stock_id, item_code, warehouse_id, quantity · → Movement(logged_in) · ← Item, Warehouse |
| Movement | Entity | holds movement_id, stock_id, direction, quantity · ← Stock |
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. |
Diagram text
Paste this text into the editor to get the same picture, then change the names to fit your own work.
# Inventory ERD
erDiagram
Item {
int item_code PK
varchar item_name
}
Warehouse {
int warehouse_id PK
varchar location
}
Stock {
int stock_id PK
int item_code FK
int warehouse_id FK
int quantity
}
Movement {
int movement_id PK
int stock_id FK
varchar direction
int quantity
}
Item ||--o{ Stock : stored_as
Warehouse ||--o{ Stock : holds
Stock ||--o{ Movement : logged_in