# Data dictionary

Generated by site/render.py from the dbt YAML files. Synthetic data; see README.md.

## Raw extracts (schema `raw`)

- `product_workspaces` (product): Every workspace with its signup day.
- `product_plan_changes` (product): Each change of a workspace's plan kind (free, self_serve, contract), from signup on.
- `product_workspace_monthly` (product): Month-end snapshot of each workspace's active seats and plan kind.
- `card_price_list` (card): Seat prices per plan and interval, and the price per metered run.
- `card_customers` (card): One billing customer per paying workspace.
- `card_subscriptions` (card): Seat plan subscriptions with start, end, status and recurring discount.
- `card_seat_changes` (card): Seat count after each change, including the starting seats.
- `card_invoice_lines` (card): Invoice lines (recurring, proration, usage, late usage).
- `card_refunds` (card): Refunds of the unused part of a period, one per refunded line.
- `usage_daily` (usage): Metered runs per workspace per day, with the time each row was loaded.
- `crm_accounts` (crm): Accounts, most linked to a workspace.
- `crm_opportunities` (crm): Opportunities (new, migration, renewal), won or lost, with total contract value.
- `crm_contracts` (crm): Signed contracts with service dates, term, discount, billing frequency and onboarding fee.
- `crm_contract_tiers` (crm): Ramp tiers, one per contract year, with the annual list value.
- `contract_invoice_lines` (invoicing): Invoice lines from contract schedules (recurring, one-off, usage, late usage).
- `contract_payments` (invoicing): Bank transfer payments against contract invoices.
- `contract_credits` (invoicing): Credit notes (goodwill and service credits).

## Staging

### stg_product_workspaces

Workspaces, typed.

| Column | Description |
|---|---|
| `workspace_id` | Workspace key. |
| `signed_up_on` | Signup day. |
| `initial_seats` | Seats at signup. |

### stg_product_plan_changes

Plan kind changes per workspace, typed.

| Column | Description |
|---|---|
| `workspace_id` | Workspace. |
| `effective_date` | First day of the new plan kind. |
| `plan_kind` | free, self_serve or contract. |

### stg_product_workspace_monthly

Month-end workspace snapshot, typed.

| Column | Description |
|---|---|
| `workspace_id` | Workspace. |
| `month_end` | Last day of the month. |
| `active_seats` | Seats in use at the month end. |
| `plan_kind` | Plan kind at the month end. |

### stg_card_price_list

Card price list, typed.

| Column | Description |
|---|---|
| `price_id` | Price key. |
| `plan` | team, business, or usage for the run price. |
| `billing_interval` | monthly, annual, or run. |
| `unit_amount` | US$ per seat per interval, or per run. |

### stg_card_customers

Card billing customers, typed.

| Column | Description |
|---|---|
| `customer_id` | Billing customer key. |
| `workspace_id` | The workspace this customer pays for. A workspace has at most one billing customer. |
| `created_on` | Day the billing customer was created. |

### stg_card_subscriptions

Card subscriptions, typed.

| Column | Description |
|---|---|
| `subscription_id` | Subscription key. |
| `customer_id` | Paying customer. |
| `price_id` | Seat price (plan and interval). |
| `started_on` | First service day; billing periods start on this day of the month. |
| `ended_on` | Last service day, empty while the subscription runs. |
| `status` | active or cancelled at the extract. |
| `recurring_discount_pct` | Discount in percent applied to every recurring charge. |

### stg_card_seat_changes

Seat changes, typed.

| Column | Description |
|---|---|
| `change_id` | Change key. |
| `subscription_id` | Subscription. |
| `effective_date` | Day the new seat count takes effect. |
| `seats_after` | Seats from that day on. |

### stg_card_invoice_lines

Card invoice lines, typed.

| Column | Description |
|---|---|
| `line_id` | Line key. |
| `invoice_id` | Invoice the line belongs to. |
| `customer_id` | Billed customer. |
| `subscription_id` | Subscription, on recurring and proration lines. |
| `workspace_id` | Metered workspace, on usage lines. |
| `line_type` | recurring, proration, usage or usage_late. |
| `invoice_date` | Day the line was invoiced. |
| `period_start` | First day the line pays for. |
| `period_end` | Last day the line pays for. |
| `quantity` | Seats, added seats, or runs. |
| `amount` | US$. |

### stg_card_refunds

Card refunds, typed.

| Column | Description |
|---|---|
| `refund_id` | Refund key. |
| `line_id` | Refunded invoice line. |
| `refund_date` | Day of the refund. |
| `amount` | US$ refunded. |

### stg_usage_daily

Metered usage, typed.

| Column | Description |
|---|---|
| `usage_id` | Row key. |
| `workspace_id` | Workspace. |
| `usage_date` | Day the runs happened. |
| `runs` | Metered runs that day. |
| `loaded_at` | When the row reached the extract. |

### stg_crm_accounts

CRM accounts, typed.

| Column | Description |
|---|---|
| `account_id` | Account key. |
| `workspace_id` | Linked workspace, empty when the link is missing. |
| `segment` | mid_market or large. |
| `created_on` | Day the account was created. |

### stg_crm_opportunities

CRM opportunities, typed.

| Column | Description |
|---|---|
| `opportunity_id` | Opportunity key. |
| `account_id` | Account. |
| `opportunity_type` | new, migration or renewal. |
| `stage` | closed_won or closed_lost. |
| `close_date` | Day the opportunity closed. |
| `amount` | Total contract value in US$, net of discount. |

### stg_crm_contracts

CRM contracts, typed.

| Column | Description |
|---|---|
| `contract_id` | Contract key. |
| `account_id` | Account. |
| `opportunity_id` | The won opportunity. |
| `signed_on` | Signature day. |
| `service_start` | First service day. ARR starts here. |
| `service_end` | Last service day. |
| `term_months` | Term in months. |
| `discount_pct` | Discount in percent on every tier. |
| `billing_frequency` | annual or quarterly, in advance. |
| `onboarding_fee` | One-off fee in US$, invoiced with the first invoice; 0 when none. |

### stg_crm_contract_tiers

Ramp tiers, typed.

| Column | Description |
|---|---|
| `contract_id` | Contract. |
| `tier` | Tier number, from 1. |
| `tier_start` | First day of the tier. |
| `tier_end` | Last day of the tier. |
| `annual_list_value` | Annual list value in US$ before the contract discount. |

### stg_contract_invoice_lines

Contract invoice lines, typed.

| Column | Description |
|---|---|
| `line_id` | Line key. |
| `invoice_id` | Invoice the line belongs to. |
| `contract_id` | Contract. |
| `workspace_id` | Metered workspace, on usage lines. |
| `line_type` | recurring, one_off, usage or usage_late. |
| `invoice_date` | Invoice day. |
| `period_start` | First day the line pays for. |
| `period_end` | Last day the line pays for. |
| `quantity` | 1, or runs on usage lines. |
| `amount` | US$. |

### stg_contract_payments

Payments, typed.

| Column | Description |
|---|---|
| `payment_id` | Payment key. |
| `invoice_id` | Paid invoice. |
| `paid_on` | Day the transfer arrived. |
| `amount` | US$ received. |

### stg_contract_credits

Credit notes, typed.

| Column | Description |
|---|---|
| `credit_id` | Credit key. |
| `contract_id` | Contract credited. |
| `issued_on` | Day the credit note was issued. |
| `credit_type` | goodwill or service. |
| `amount` | US$ credited (positive). |

## Intermediate

### int_days

One row per day from the first paid month to the last day of customer behaviour.

| Column | Description |
|---|---|
| `day` | Calendar day. |

### int_months

One row per calendar month; is_reported marks the 18 reported months.

| Column | Description |
|---|---|
| `month_start` | First day of the month. |
| `month_end` | Last day of the month. |
| `days_in_month` | Days in the month. |
| `is_reported` | True for the 18 reported months. |

### int_identity_bridge

One row per workspace with its billing customer and its linked CRM account, when they exist.

| Column | Description |
|---|---|
| `workspace_id` | Workspace. |
| `customer_id` | Card billing customer, if any. |
| `account_id` | Linked CRM account, if any. |

### int_account_keys

The customer key each CRM account's ARR is tracked under (its workspace when linked).

| Column | Description |
|---|---|
| `account_id` | CRM account. |
| `workspace_id` | Linked workspace, if any. |
| `customer_key` | Workspace id, or 'account:' plus the account id when unlinked. |

### int_card_subscriptions

Card subscriptions with price, workspace and billing period length.

| Column | Description |
|---|---|
| `subscription_id` | Subscription. |
| `step_months` | Billing period length in months (1 or 12). |
| `annualise` | Factor from the period price to an annual value (12 or 1). |

### int_card_seat_intervals

Seats in effect over each stretch of days, and the change from the stretch before.

| Column | Description |
|---|---|
| `subscription_id` | Subscription. |
| `valid_from` | First day of the stretch. |
| `valid_to` | Last day of the stretch. |
| `seats` | Seats in effect. |
| `seat_delta` | Change in seats from the previous stretch. |

### int_card_periods

Billing periods of each card subscription, rebuilt from its start day and interval.

| Column | Description |
|---|---|
| `subscription_id` | Subscription. |
| `period_start` | Period start. |
| `period_end` | Period end. |

### int_card_charges

The charges the card billing rules say should exist (recurring at each period start, prorated for each seat increase inside a period), rebuilt from subscriptions and seat changes only.

| Column | Description |
|---|---|
| `subscription_id` | Subscription. |
| `line_type` | recurring or proration. |
| `amount` | Expected amount in US$, rounded to cents as billing does. |
| `window_days` | Days of service the charge pays for. |
| `recognise_until` | Last day revenue is recognised (the subscription's last day, if earlier). |

### int_card_recognition

Card revenue recognised by subscription and month, ratably by day from the rebuilt charges.

| Column | Description |
|---|---|
| `subscription_id` | Subscription. |
| `month_start` | Month. |
| `recognised` | US$ recognised. |
| `recognised_from_proration` | The part of it from prorated charges. |

### int_contract_periods

Billing periods of each contract (annual or quarterly in advance from service start).

| Column | Description |
|---|---|
| `contract_id` | Contract. |
| `period_start` | Period start. |
| `period_end` | Period end. |

### int_contract_charges

The charges each contract schedule says should exist (tier at period start, net of discount; onboarding fee).

| Column | Description |
|---|---|
| `contract_id` | Contract. |
| `line_type` | recurring or one_off. |
| `amount` | Expected amount in US$. |

### int_contract_recognition

Contract revenue by contract and month under version 1 (each recurring charge by day over its own period, fees on their day). The walk's straight-lining line compares the policy figure with this one.

| Column | Description |
|---|---|
| `contract_id` | Contract. |
| `recognised_recurring` | US$ from recurring charges. |
| `recognised_one_off` | US$ from onboarding fees. |

### int_contract_terms

Each contract's term and total scheduled value: every period's scheduled charge through the service end, in whole cents rounded half up, plus the onboarding fee.

| Column | Description |
|---|---|
| `contract_id` | Contract. |
| `term_days` | Days from service start to service end, both included. |
| `scheduled_value` | US$ the schedule bills over the whole term. |
| `onboarding_fee` | US$ onboarding fee (0 when none). |

### int_contract_recognition_straight

Contract revenue by contract and month under version 2: the scheduled value and the onboarding fee spread evenly by day over the service term.

| Column | Description |
|---|---|
| `contract_id` | Contract. |
| `recognised_recurring` | US$ of the scheduled value earned in the month. |
| `recognised_one_off` | US$ of the onboarding fee earned in the month. |

### int_contract_revenue

Contract revenue under the declared policy (var recognition_policy): straight_line (version 2, the default) or billing_period (version 1).

| Column | Description |
|---|---|
| `contract_id` | Contract. |
| `recognised_recurring` | US$ from the contract's scheduled value. |
| `recognised_one_off` | US$ from the onboarding fee. |

### int_plan_intervals

Each workspace's plan kind over stretches of days, from the product's plan changes.

| Column | Description |
|---|---|
| `workspace_id` | Workspace. |
| `plan_kind` | free, self_serve or contract. |
| `is_paid` | True unless free. |

### int_paid_islands

Unbroken paid stretches per workspace (a migration counts as one stretch).

| Column | Description |
|---|---|
| `workspace_id` | Workspace. |
| `paid_from` | First paid day. |
| `paid_to` | Last paid day (capped at the last day). |

### int_usage_rows

Usage rows with plan kind, lateness, billing day under the day-5 rule and revenue.

| Column | Description |
|---|---|
| `usage_id` | Row. |
| `is_billable` | The workspace was paid on the row's day. |
| `is_late` | Loaded on or after day 5 of the next month, after the month's usage was final. |
| `bill_date` | Day the row is billed (day 5 of the next month, or of the month after if late). |
| `revenue` | Runs times the run price, US$. |

### int_usage_monthly

Per workspace and month, paid-every-day and paid-at-month-end flags and usage revenue.

| Column | Description |
|---|---|
| `workspace_id` | Workspace. |
| `paid_all_month` | Paid on every day of the month. |
| `final_revenue` | Usage revenue from rows that arrived before the month was final. |

### int_usage_arr_monthly

Usage run-rate ARR per workspace paid at the month end, with the months counted and a flag.

| Column | Description |
|---|---|
| `workspace_id` | Workspace. |
| `months_counted` | Complete paid months among this one and the two before. |
| `usage_arr` | US$ run rate. |
| `history_flag` | complete, short_history or too_new. |

### int_arr_daily

The daily ARR spine, one row per line item (card subscription or contract) per day in service.

| Column | Description |
|---|---|
| `line_id` | Subscription or contract. |
| `motion` | self_serve or sales_led. |
| `day` | Day. |
| `arr` | Annualised value in effect that day, US$. |

### int_arr_line_monthly

Per line and month, ARR at the month end, daily ARR summed, recognised revenue, start and end flags.

| Column | Description |
|---|---|
| `line_id` | Subscription or contract. |
| `arr_end` | ARR on the month's last day. |
| `arr_day_sum` | Daily ARR summed over the month's days in service. |
| `recognised` | Recognised revenue of the line in the month. |

### int_customer_arr_monthly

ARR per customer key, motion and month end, with zero rows once a key has had ARR.

| Column | Description |
|---|---|
| `customer_key` | Workspace, or account when unlinked. |
| `motion` | self_serve, sales_led or usage. |
| `arr` | US$ at the month end. |

### int_arr_bridge_rows

Each customer key's ARR movement per motion and month (new, expansion, contraction, churn, reactivation, migration, usage change).

| Column | Description |
|---|---|
| `customer_key` | Workspace, or account when unlinked. |
| `motion` | self_serve, sales_led or usage. |
| `month_start` | Month. |

## Marts

### dim_identity_bridge

One row per workspace with its billing customer and CRM account, plus one row per CRM account with no workspace link. customer_key is the key ARR is tracked under.

| Column | Description |
|---|---|
| `workspace_id` | Workspace; empty on rows for unlinked accounts. At most one row per workspace. |
| `customer_id` | Card billing customer, if any. |
| `account_id` | CRM account, if any. |
| `customer_key` | Workspace id, or 'account:' plus the account id when unlinked. |
| `has_billing_customer` | The workspace pays or paid by card. |
| `has_crm_account` | A CRM account is linked. |

### fct_arr_monthly

Headline ARR at each reported month end: contracted recurring (self-serve plus sales-led) plus usage run rate, as components and a total.

| Column | Description |
|---|---|
| `month_start` | Month. |
| `month_end` | The month end ARR is measured at. |
| `arr_self_serve` | Card seat plans in service on the last day, seats times net price, annualised (US$). |
| `arr_sales_led` | Contracts in service on the last day, the tier in effect net of discount (US$). |
| `arr_contracted` | arr_self_serve plus arr_sales_led. |
| `arr_usage` | Usage run rate of workspaces paid on the last day (US$). |
| `arr_total` | Headline ARR, contracted plus usage. |
| `self_serve_customers` | Customer keys with self-serve ARR. |
| `sales_led_customers` | Customer keys with sales-led ARR. |
| `usage_workspaces` | Workspaces with usage ARR. |
| `usage_short_history` | Workspaces whose usage run rate rests on one or two complete months (flagged). |
| `usage_too_new` | Paid workspaces with no complete month yet (usage ARR 0, flagged). |

### fct_arr_bridge

Monthly ARR bridge by motion (self_serve, sales_led, usage) and consolidated (total). Migration in and out are equal in the total, so they net to zero.

| Column | Description |
|---|---|
| `month_start` | Month. |
| `motion` | self_serve, sales_led, usage or total. |
| `opening` | ARR at the previous month end. |
| `new` | ARR from customer keys with none before in this motion. |
| `expansion` | Increases (for a migration, the contract's ARR above the old self-serve ARR). |
| `contraction` | Decreases short of zero. |
| `churn` | ARR of customer keys that dropped to zero (not migrations). |
| `reactivation` | ARR of customer keys returning after an earlier stop. |
| `migration_in` | Self-serve ARR arriving in sales-led with a migration. |
| `migration_out` | Self-serve ARR leaving with a migration. |
| `usage_change` | Change in usage run rate (usage moves only through this column). |
| `closing` | ARR at the month end. |
| `new_customers` | Customer keys counted as new. |
| `churned_customers` | Customer keys counted as churned. |
| `migrations` | Customer keys that migrated from self-serve to a contract. |

### fct_revenue_monthly

Recognised revenue by month and stream, from the rebuilt schedules and usage rows (never from invoices).

| Column | Description |
|---|---|
| `month_start` | Month. |
| `card` | Card seat plans, ratably by day. |
| `contract` | Contract revenue under the declared policy (straight-line over the term by default). |
| `one_off` | Onboarding fees under the declared policy (spread over the term by default). |
| `usage` | Usage in the month consumed. |
| `credits` | Credit notes, negative. |
| `total` | Recognised revenue. |

### fct_deferred_rollforward

Deferred revenue roll-forward by month and stream (card, contract, usage): opening + billings minus recognised = closing, set against a balance computed from the documents. Negative balances are revenue earned but not yet invoiced. Under version 2 the contract documents balance is invoiced to date less straight-line revenue to date.

| Column | Description |
|---|---|
| `month_start` | Month. |
| `stream` | card, contract or usage. |
| `opening` | The previous month end's document balance. |
| `billings` | Documents dated in the month (invoice lines less refunds and credit notes). |
| `recognised` | Revenue recognised in the month. |
| `closing` | opening plus billings minus recognised. |
| `closing_from_documents` | Card: unearned share of every invoice line still to come. Usage: minus usage consumed and not yet billed. Contract, under the straight-line policy: invoiced to date less straight-line revenue to date, the same inputs as the roll-forward, so the contract leg holds by construction. |
| `difference` | closing minus closing_from_documents (within US$1 when the documents agree with the schedules). |

### fct_arr_to_revenue

From ARR to recognised revenue by month: headline ARR / 12, plus ramps, seat changes and proration, starts and ends, the days in the month and billing periods (what remains on each line), straight-lining, usage actual against run rate, one-off fees and credits, equals recognised revenue (item recognised_revenue).

| Column | Description |
|---|---|
| `month_start` | Month. |
| `step` | Order in the walk. |
| `item` | Name of the step. |
| `amount` | US$. |

### fct_usage_restatements

Usage rows that arrived after their month was final, listed by workspace and month, with the ARR they would have changed.

| Column | Description |
|---|---|
| `month_start` | Usage month. |
| `workspace_id` | Workspace. |
| `late_rows` | Late rows. |
| `late_runs` | Runs in them. |
| `late_revenue` | Their revenue (billed as late usage the month after). |
| `first_loaded_at` | When the first of them arrived. |
| `arr_effect` | Change to that month's usage ARR had they arrived on time. |

### fct_naive_vs_defined_arr

Naive ARR (every billing document dated in the month, times 12) against defined ARR.

| Column | Description |
|---|---|
| `month_start` | Month. |
| `card_seats_billed` | Card recurring and proration lines. |
| `contract_recurring_billed` | Contract recurring lines. |
| `usage_billed` | Usage lines of both systems (last month's usage). |
| `one_off_billed` | Onboarding fees. |
| `refunds_and_credits` | Refunds and credit notes, negative. |
| `billed_total` | Everything billed in the month. |
| `naive_arr` | billed_total times 12. |
| `defined_arr` | Headline ARR from fct_arr_monthly. |
| `gap` | naive_arr minus defined_arr. |
| `gap_share` | gap as a share of defined ARR. |

### fct_contract_balances

Contract balances by reported month under the declared policy. Per contract, invoiced to date less recognised to date: a positive balance is deferred revenue, a negative one unbilled revenue (a contract asset). Credits reduce billings and revenue alike, so they are left out of both.

| Column | Description |
|---|---|
| `month_start` | Month. |
| `deferred_revenue` | US$ summed over contracts with a positive balance. |
| `unbilled_revenue` | US$ (negative) summed over contracts with a negative balance. |
| `contracts_deferred` | Contracts with a positive balance. |
| `contracts_unbilled` | Contracts with a negative balance. |
