Diagram Desk

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

MenuPK menu_id intmenu_name varcharprice intOrdersPK order_id intordered_at datetimeOrderLinePK line_id intFK order_id intFK menu_id intquantity intPaymentPK payment_id intFK order_id intmethod varcharcontainsordered_aspaid_by
ER diagram · 16 shapes

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

ShapeSymbolConnections
MenuEntityholds menu_id, menu_name, price · → OrderLine(ordered_as)
OrdersEntityholds order_id, ordered_at · → OrderLine(contains), Payment(paid_by)
OrderLineEntityholds line_id, order_id, menu_id, quantity · ← Orders, Menu
PaymentEntityholds payment_id, order_id, method · ← Orders

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 oneA bar and a circle.
Zero or manyA crow's foot and a circle.
One or manyA crow's foot and a bar.

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.

# 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

More er diagram examples

All SeewolLabs tools