# Table guide: which tables are current

Answer from the six current tables below. The warehouse also holds twelve look-alike tables. None of them is a source
of truth, and none should be read for a reported figure.

## Current tables

- accounts: one row per account (account_id), with its organization, currency, status and opening balance.
- cards: one row per card (card_id). cards.account_id references accounts.
- categories: one row per spending category (category_id).
- transactions: one row per ledger event (transaction_id). This is the source of truth for events.
- card_spend_daily: the card spend mart, one row per posting date, card and category.
- account_daily: the daily balance mart, one row per account and date from 2026-07-01 through 2026-08-02.

## Look-alikes: do not read these

Each of card_spend_daily, transactions and account_daily has four look-alikes with the same columns:

- card_spend_daily_v1, transactions_v1, account_daily_v1: old builds under retired definitions. card_spend_daily_v1
  dates spend by when a purchase was initiated, not when it posted. transactions_v1 stores debit amounts as negative
  numbers. account_daily_v1 counts pending events in balances.
- card_spend_daily_backup, transactions_backup, account_daily_backup: stale copies taken before 2026-07-25. Later
  dates are missing, and events that posted later still show as pending.
- stg_card_spend_daily, stg_transactions, stg_account_daily: staging copies with test accounts and test cards mixed in.
- analytics.card_spend_daily, analytics.transactions, analytics.account_daily: copies in the analytics schema for a
  dashboard of active cards. Spending and events on frozen or cancelled cards are missing.

## How the current tables join

- card_spend_daily and account_daily join accounts on account_id.
- card_spend_daily joins cards on card_id, and categories on category_id with a LEFT JOIN: a NULL category is a real
  bucket.
- transactions joins accounts on account_id, cards on card_id, and categories on category_id with a LEFT JOIN.
- A refund's related_transaction_id is its original purchase's transaction_id.
- Aggregate account_daily on the requested date before joining anything to it; joining card or transaction rows to
  daily balance rows repeats the balance.
