← Gallery
Diagram
er
← Prev
Next →
Entity relationship
Order model
Order model
Four entities read left to right, referenced entity before referencing entity. A customer places zero or many orders; each order contains one or many order lines; each order line is priced by exactly one product, and a product may appear on zero or many order lines. Order is the anchor entity. Cardinality is written as text at both ends of every relationship.
1
places
0..*
1
contains
1..*
0..*
priced by
1
Customer
Table
#
customer_id
uuid
email
text
full_name
text
created_at
date
Order
Table
#
order_id
uuid
placed_at
date
→
customer_id
Customer
status
text
total_amount
numeric
OrderLine
Table
#
order_id
→ Order
#
line_no
int
→
product_id
Product
quantity
int
unit_price
numeric
Product
Table
#
product_id
uuid
sku
text
name
text
list_price
numeric
Cardinality notation — 1 exactly one, 1..* one or many, 0..* zero or many; read at each end of a relationship. Markers — # primary key, → foreign key.
OrderLine keeps its own attributes, so it is drawn as an entity rather than collapsed into a many-to-many line. Payment and shipment relationships are out of scope for this view.