Global pitfalls:
  ⚠ Pitfall: timestamps stored as text are UTC

Never query:
  ⚠ shop.broken_child — abandoned migration copy

Legend:
  ⚠ a hazard: measured, declared by a person, or drafted (then marked (draft)).
  ≈ / ≥ estimated from a sample of a large table; never verified.
  (draft) written by a language model and not checked.
  measured <date> an observed number; verified <date> a claim that passed its check.
  (human, unchecked) / (declared, unchecked) stated by a person or a declaration; not yet checked against the data.
  Absence of a warning is not verification.

Glossary:
  revenue: sum of payments.amount over paid orders [tables: shop.orders, shop.payments]

[shop.events] One row per tracked user event. (draft)
  ⚠ session_id → shop.orders.order_id BROKEN: match 0% (measured 2026-11-20) — do not join on it
  20,000 rows (measured 2026-11-20)
  Keys: PK event_id; account_id → shop.accounts.account_id (N:1, match 100%); session_id → shop.sessions.session_id (N:1, match 100%)

[shop.sessions]
  5,000 rows (measured 2026-11-20)
  Keys: PK session_id

[shop.accounts] One row per business account.
  100 rows (measured 2026-11-20)
  Keys: PK account_id

[shop.orders] One row per order. (draft)
  ⚠ Pitfall (critical): a refund is a second payment row with a negative amount — fix: SUM(amount) nets refunds; count paid orders by status instead
  ⚠ status: declared values 'paid','refunded','cancelled' — observed also 'PAID' (412 rows)
  ⚠ status: case drift: 'paid'/'PAID' differ only in case — compare case-insensitively
  ⚠ created_at: stored as VARCHAR, holds ISO-8601 timestamp (100% of values, measured 2026-11-20) — CAST before comparing
  Answers (draft): revenue; order volume; basket size
  10,000 rows (measured 2026-11-20)
  Keys: PK order_id; account_id → shop.accounts.account_id (N:1, match 100%); customer_id → shop.customers.customer_id (N:1, match 98.04%)
  live rows: (deleted IS NULL OR NOT deleted) (verified 2026-11-19)

[shop.customers] One row per customer account holder.
  Answers: customer segments; retention
  1,000 rows (measured 2026-11-20)
  Keys: PK customer_id

Join paths (join keys, advisory; support = the weakest hop's match or coverage):
  ⚠ no safe route (shop.events -> shop.orders; shop.events -> shop.customers; shop.sessions -> shop.orders; shop.sessions -> shop.customers): every route pivots through hub shop.accounts on two attribution edges (fan-in > 10): a cartesian hazard
  shop.events → shop.sessions · support 100%
    events.session_id = sessions.session_id (N:1)
  shop.events → shop.accounts · support 100%
    events.account_id = accounts.account_id (N:1)
  shop.accounts → shop.orders · support 40%
    orders.account_id = accounts.account_id (N:1)
  shop.orders → shop.customers · support 98.04%
    orders.customer_id = customers.customer_id (N:1)

Not shown: no other candidate tables.
