Data Analyst & Analytics Interview · Data Modeling & the Modern Stack · Lesson 1 of 2
Star schemas: facts, dimensions & grain
Analyst and analytics-engineer loops routinely ask you to design a schema: 'model the data for a food-delivery app.' The expected answer in a warehouse is dimensional modeling — a central fact table of measurable events surrounded by descriptive dimension tables. The shape gives it its name: a star schema.
- Fact table: one row per business event at a declared grain (an order line, a trip, an impression), holding measures (amount, quantity) plus foreign keys to dimensions.
- Dimension tables: the who/what/where/when context —
dim_customer,dim_product,dim_date. Wide, descriptive, and what you filter and group by. - Grain: the sentence that defines a fact row — 'one row per order line item'. State it first; every measure and join follows from it.
- Star vs snowflake: a snowflake normalizes dimensions into sub-tables. Analytics defaults to the star — fewer joins, simpler for BI tools and other analysts.
- Additivity: revenue sums across any dimension (additive); an account balance does not sum over time (semi-additive — snapshot facts need care).
-- The star in action: revenue by product category and month SELECT d.month, p.category, SUM(f.amount) AS revenue FROM fact_order_items f JOIN dim_date d ON d.date_key = f.date_key JOIN dim_product p ON p.product_key = f.product_key GROUP BY d.month, p.category;
Say the grain firstThe strongest opening move in a modeling question is one sentence: 'The grain is one row per order line item.' Which measures are valid, which dimensions attach, why a SUM is safe — all of it follows. Skipping the grain is the #1 way candidates produce a muddled schema.
Dimensions change: SCDsA customer moves cities — overwrite, or keep history? Type 1 overwrites (no history). Type 2 adds a new row with validity dates, so facts join to the state at the time of the event — the analytics default. Saying 'SCD Type 2' unprompted when an attribute changes over time reads as senior.
◆ Lock it in
- A star schema = fact table (events + measures at one grain) joined to dimensions (context).
- Declare the grain in one sentence before anything else.
- Changing attributes → SCD Type 2 (new row + validity dates) to preserve history.
Feynman drill — say it out loudDesign a mini star schema for a coffee-shop chain out loud: state the grain, the measures, three dimensions — and where an SCD would appear.
Step 1 rate your confidence · Step 2 pick your answer
'One row per completed trip' in a ride-share warehouse is a statement of the fact table's what?
Step 1 — how sure are you?