Database schema · Diagram Design

Commerce schema · public + billing

The physical schema behind checkout: five tables, real SQL types, and foreign keys that anchor column to column, not box to box. The dashed group marks the non-default `billing` schema.

Commerce schema · public + billing Physical database schema diagram showing five commerce tables with column-level foreign keys, SQL types, and constraint chips, including a cascading delete from orders into order_items and a billing schema group. BILLING ON DELETE RESTRICT ON DELETE CASCADE ON DELETE RESTRICT ON DELETE RESTRICT public.customers TABLE id PK uuid email UQ NN text created_at NN timestamptz public.orders TABLE id PK uuid customer_id FK NN uuid status NN text total NN numeric(12,2) placed_at NN timestamptz INDEXES idx_orders_customer_id idx_orders_status public.order_items TABLE id PK uuid order_id FK NN uuid product_id FK NN uuid qty NN integer unit_price NN numeric(12,2) public.products TABLE id PK uuid sku UQ NN text name NN text price NN numeric(12,2) + 3 more columns INDEXES uq_products_sku billing.invoices TABLE id PK uuid order_id FK NN uuid issued_at NN timestamptz LEGEND Table Schema group PK Constraint chip Foreign key (column to column) Destructive delete (CASCADE)

THE DESTRUCTIVE EDGE

Deleting an order cascades

`order_items.order_id` is the one `ON DELETE CASCADE` in this schema — remove an order and its line items go with it. Every other foreign key is `RESTRICT`.

Column to column, not box to box

  • Every FK anchors to a specific row on both ends
  • Fixed 24px row height keeps anchors predictable
  • The `ON DELETE` label is the point of the edge

Scoped to the subsystem

`products` truncates to a `+ 3 more columns` row rather than dumping every column. This is checkout, not a `\d+` of the whole database.