All fixtures · From the Format page · format/92-er-diagram.dh.md
Source
---
title: "ER: tables and their keys"
description: An entity-relationship diagram with crow's-foot lines from key to key (SPEC 3.2 ER). Shown live, then static.
---
## ER: tables and their keys
An `er` part draws tables with their keys and joins them with crow's-foot lines, each from the key to what it points at. A step may light a table or a column.
```er title="Shop"
entity customer "Customer" [c1]
id uuid pk
email text unique
entity order "Order" [c2]
id uuid pk
customer_id uuid fk -> customer.id
placed_at timestamptz
entity line "Order line" [c2]
order_id uuid fk -> order.id
product text
quantity int
customer 1 -- 0..* order "places"
order 1 -- 1..* line "holds"
@step Start from the customer's key.
highlight customer.id
@step Each order keeps it in `customer_id`.
highlight order.customer_id
@step Each line of an order keeps the order's key in `order_id`.
highlight line.order_id
```
The same diagram, static:
```er static=true title="Shop, static"
entity customer "Customer" [c1]
id uuid pk
email text unique
entity order "Order" [c2]
id uuid pk
customer_id uuid fk -> customer.id
placed_at timestamptz
entity line "Order line" [c2]
order_id uuid fk -> order.id
product text
quantity int
customer 1 -- 0..* order "places"
order 1 -- 1..* line "holds"
@step Start from the customer's key.
highlight customer.id
@step Each order keeps it in `customer_id`.
highlight order.customer_id
@step Each line of an order keeps the order's key in `order_id`.
highlight line.order_id
```
LLM view
---
title: "ER: tables and their keys"
description: An entity-relationship diagram with crow's-foot lines from key to key (SPEC 3.2 ER). Shown live, then static.
source: format/92-er-diagram.dh.md
---
<!-- Made by dh llm from the source; nobody edits this file. -->
## ER: tables and their keys
An `er` part draws tables with their keys and joins them with crow's-foot lines, each from the key to what it points at. A step may light a table or a column.
ER diagram: Shop.
customer (Customer): id uuid pk; email text unique
order (Order): id uuid pk; customer_id uuid fk -> customer.id; placed_at timestamptz
line (Order line): order_id uuid fk -> order.id; product text; quantity int
A customer places 0 or more orders; an order belongs to exactly 1 customer. An order holds 1 or more lines; a line belongs to exactly 1 order.
1. Start from the customer's key.
lit: customer.id
2. Each order keeps it in `customer_id`.
lit: order.customer_id
3. Each line of an order keeps the order's key in `order_id`.
lit: line.order_id
The same diagram, static:
ER diagram: Shop, static.
customer (Customer): id uuid pk; email text unique
order (Order): id uuid pk; customer_id uuid fk -> customer.id; placed_at timestamptz
line (Order line): order_id uuid fk -> order.id; product text; quantity int
A customer places 0 or more orders; an order belongs to exactly 1 customer. An order holds 1 or more lines; a line belongs to exactly 1 order.
1. Start from the customer's key.
lit: customer.id
2. Each order keeps it in `customer_id`.
lit: order.customer_id
3. Each line of an order keeps the order's key in `order_id`.
lit: line.order_idER: tables and their keys
An er part draws tables with their keys and joins them with crow's-foot lines, each from the key to what it points at. A step may light a table or a column.
ER diagram: Shop. customer (Customer): id uuid pk; email text unique order (Order): id uuid pk; customer_id uuid fk -> customer.id; placed_at timestamptz line (Order line): order_id uuid fk -> order.id; product text; quantity int A customer places 0 or more orders; an order belongs to exactly 1 customer. An order holds 1 or more lines; a line belongs to exactly 1 order. 1. Start from the customer's key. lit: customer.id 2. Each order keeps it in `customer_id`. lit: order.customer_id 3. Each line of an order keeps the order's key in `order_id`. lit: line.order_id
All steps (3)
The same diagram, static:
ER diagram: Shop, static. customer (Customer): id uuid pk; email text unique order (Order): id uuid pk; customer_id uuid fk -> customer.id; placed_at timestamptz line (Order line): order_id uuid fk -> order.id; product text; quantity int A customer places 0 or more orders; an order belongs to exactly 1 customer. An order holds 1 or more lines; a line belongs to exactly 1 order. 1. Start from the customer's key. lit: customer.id 2. Each order keeps it in `customer_id`. lit: order.customer_id 3. Each line of an order keeps the order's key in `order_id`. lit: line.order_id
3 Each line of an order keeps the order's key in order_id.
All steps (3)
- Start from the customer's key.
- Each order keeps it in
customer_id. - Each line of an order keeps the order's key in
order_id.