Data modeling cheat sheet
Grain, star schemas, SCD types, and medallion layers — one printable page.
Grain and keys
One row per order per day- Write the grain in the model YAML before you write SQL.
surrogate_key = hash(business_keys)- Stable warehouse keys; never reuse natural keys that change.
Star schema
fact_* + dim_*- Facts hold measures at one grain; dimensions hold descriptive attributes.
degenerate dimension- A fact column that is also a dimension (order_id on a line-item fact).
SCD
Type 1: overwrite- No history. Fine for typo fixes.
Type 2: valid_from / valid_to / is_current- The default for customers, products, employees.
Medallion
bronze → silver → gold- Each layer rebuildable from the one below. Gold is what BI queries.
From DataLane — tutorials at/blog, practice SQL live in theplayground.