Diagram Desk

Inventory ERD

Item, warehouse, stock and movement. Stock links items to warehouses; movements record every change.

The diagram

ItemPK item_code intitem_name varcharWarehousePK warehouse_id intlocation varcharStockPK stock_id intFK item_code intFK warehouse_id intquantity intMovementPK movement_id intFK stock_id intdirection varcharquantity intstored_asholdslogged_in
ER diagram · 16 shapes

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

ShapeSymbolConnections
ItemEntityholds item_code, item_name · → Stock(stored_as)
WarehouseEntityholds warehouse_id, location · → Stock(holds)
StockEntityholds stock_id, item_code, warehouse_id, quantity · → Movement(logged_in) · ← Item, Warehouse
MovementEntityholds movement_id, stock_id, direction, quantity · ← Stock

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.

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.

# 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

More er diagram examples

All SeewolLabs tools