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
  sampled table: ≈ and ≥ figures are estimates from a sample
  20,000 rows (measured 2026-11-20)
  Columns:
    event_id    INTEGER  PK (declared, enforced)
    session_id  VARCHAR  → shop.orders.order_id BROKEN (see warning); → shop.sessions.session_id N:1, match 100% (measured 2026-11-20); distinct ≥ 190 (sampled 1%, lower bound)
    account_id  INTEGER  → shop.accounts.account_id N:1, match 100%, coverage 60% (measured 2026-11-20); null ≈ 0% (sampled 1%, 0% to 3.713%, approximate)
    kind        VARCHAR  values seen in sample: 'buy', 'click', 'view' (sampled 1%; rarer values may be missing)
  Provenance: drafted text marked (draft) is unchecked · measured 2026-11-20 · sampled 1%

[shop.sessions]
  5,000 rows (measured 2026-11-20)
  Columns:
    session_id  VARCHAR  PK (declared, enforced); ← shop.events.session_id (coverage 100%, measured 2026-11-20)
    started_at  VARCHAR  note: UTC start (human, unchecked)
  Provenance: human overlay · measured 2026-11-20

[shop.accounts] One row per business account.
  100 rows (measured 2026-11-20)
  Columns:
    account_id  INTEGER  PK (declared, enforced); ← shop.events.account_id (coverage 60%, measured 2026-11-20), ← shop.orders.account_id (coverage 40%, measured 2026-11-20)
    name        VARCHAR
  Provenance: human overlay · measured 2026-11-20

[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)
  Columns:
    order_id     INTEGER  PK (unique, measured 2026-11-20); ← shop.order_items.order_id (coverage 100%, measured 2026-11-20), ← shop.payments.order_id (coverage 5%, measured 2026-11-20)
    customer_id  INTEGER  → shop.customers.customer_id N:1, match 98.04% (measured 2026-11-20)
    account_id   INTEGER  → shop.accounts.account_id N:1, match 100%, coverage 40% (measured 2026-11-20)
    status       VARCHAR  values: 'paid','refunded','cancelled' (+ observed 'PAID'); Order lifecycle state. (draft)
    created_at   VARCHAR  text holding ISO-8601 timestamp (see warning)
    deleted      BOOLEAN  live rows: (deleted IS NULL OR NOT deleted) (verified 2026-11-19); holds TRUE (300 rows) or NULL (9,700 rows), never FALSE (measured 2026-11-20)
  Provenance: drafted text marked (draft) is unchecked · human overlay · measured 2026-11-20

[shop.customers] One row per customer account holder.
  Answers: customer segments; retention
  1,000 rows (measured 2026-11-20)
  Columns:
    customer_id  INTEGER  PK (unique, measured 2026-11-20); ← shop.orders.customer_id (coverage 100%, measured 2026-11-20)
    email        VARCHAR  PII email; distinct 1,000 (measured 2026-11-20)
    phone        VARCHAR  null 10% (measured 2026-11-20)
    segment      VARCHAR  values: 'retail' (334), 'wholesale' (333), 'vip' (333) (measured 2026-11-20)
  Provenance: human overlay · measured 2026-11-20

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.
