Skip to content
Tech Interview Prep
Technical interview guide

Data Warehousing & Modeling

Star and snowflake schemas, and the fact/dimension split that makes analytical queries fast.

Minutes to read
4
Practice MCQs
25
Interview Q&A
25
Edition
v5
Editorial status
Reviewed

Scope: BigQuery, Amazon Redshift, Snowflake, Apache Iceberg 1.11, PostgreSQL 18, dbt MetricFlow, and OpenLineage documentation current 2026-08-31.

Overview

Curated: · Written: · Reviewed:

Data Warehousing & Modeling

In one line

A star schema puts one fact table at a declared grain, with keys to each dimension and additive measures, so queries filter and group on dimensions and aggregate facts. Reach for it when the same business questions recur across teams and must return one agreed answer. The physical layout (partitions, clustering, distribution keys) decides whether those queries scan a little or a lot.

Key definitions

  • Grain: the sentence that says what one fact row represents. It fixes the primary key and which attributes are valid on the row.
  • Additive, semi-additive, non-additive: a measure that sums across every dimension, across all but time, or not at all.
  • Periodic snapshot: one row per entity per period end, holding balances such as month-end inventory per product per warehouse.
  • Accumulating snapshot: one row per process instance, such as an order, updated in place as each milestone date arrives.
  • Partition pruning: the engine skips every partition whose values cannot match the filter.
  • Distribution key: in a hash-distributed MPP system, the column that decides which node stores a row. Joins on that column avoid moving data between nodes.

Formulas and complexity

A join on a shared key multiplies rows wherever both sides repeat the key:

Njoin=∑kfk⋅dkN_{\text{join}}=\sum_{k} f_k \cdot d_k

where f_k is the fact rows and d_k the dimension rows carrying key k. A star with k dimensions joins k+1 tables.

Partition count grows with the product of its columns, so a high-cardinality partition key multiplies the directory count:

P=days×customers=1,095×40,000=43,800,000P=\text{days}\times\text{customers}=1{,}095\times 40{,}000=43{,}800{,}000

Ratios are derived from stored parts, never summed:

CTR=∑clicks∑impressions\mathrm{CTR}=\frac{\sum \text{clicks}}{\sum \text{impressions}}

How it works

  1. The fact table holds one surrogate key per dimension plus additive measures, all at one grain.
  2. A query filters dimension attributes, joins each dimension to the fact on its key, groups by dimension attributes and aggregates the fact measures.
  3. A Type 2 dimension is joined on the surrogate key of the version valid at the fact's business date, so each fact matches exactly one version.
  4. Physically, Hive-style tables store one directory per partition value. A filter on the partition column lists only matching directories. Snowflake keeps micro-partitions with min and max metadata, so pruning depends on how well values sit together in ingestion order; a clustering key reorders them over time. In an MPP warehouse, rows that share a distribution key land on one node, so a join on that key stays local.
Query with filter Partition or micro-partition metadata Matching partitions only Join to dimensions on keys Group and aggregate

When to use and when not to

SituationChoiceWhy
Same question asked by several teamsStar schema, conformed dimensionsPrevents definition drift
Balance per entity per month-endPeriodic snapshot, take period endBalances are semi-additive over time
Order moving through milestonesAccumulating snapshotLags come from milestone date differences
Filter mostly on date rangesPartition by dateAbout one partition per day, small directory count
Filter on a high-cardinality idSort or cluster by the idPartitioning per id creates millions of small files
Join heavy on one key in MPPDistribute on that keyJoins stay node-local, if the key spreads evenly

Traps interviewers probe

  1. Partitioning on a high-cardinality column. Fix: partition by date and cluster or sort by customer_id. 1,095 days times 40,000 customers gives 43.8 million partitions.
  2. Filtering on a transformed partition column. Fix: compare the raw column to a literal of the same type. A string dt in 'YYYY-MM-DD' supports range filters only while every value keeps that exact format, and wrapping the column in a cast can stop pruning in some engines.
  3. Summing a semi-additive balance across months. Fix: take the value at period end. Month-end balances of 1,200, 1,410 and 1,350 give a Q1 closing of 1,350, not 3,960.
  4. Reading an accumulating snapshot as an event log. Fix: the row holds only the latest milestone dates. If the question is what changed and when, keep the event history.
  5. Distributing on a skewed key. Fix: check row counts per node before choosing. One hot value sends most rows to one node, and that node finishes last.

Interview tips

Open with the grain as one sentence, then the keys, then the additivity of each measure. Name the grain before any table or physical layout.

Follow-ups to expect:

  • Partitioning or clustering: partition on a low-cardinality column that queries always filter on, cluster on the rest. Partitions that are too small add metadata and file overhead.
  • Migrating Hive partitions: check the partition column type and format first, then confirm pruning in the query plan before and after.
  • Choosing a distribution key: the join key with an even spread, and a check of skew by node.
  • Periodic or accumulating snapshot: periodic when the question is the state at each period end, accumulating when the question is how long each stage took.
  • A late-arriving dimension: load facts against a placeholder key, then restate when the real row lands, or accept the placeholder permanently. Write the choice into the contract.

30-second outline: The fact table is one row per [grain], keyed by [keys], holding [additive measures]. Dimensions [list] describe what I filter and group by. I partition on [date], cluster on [id], and distribute on [join key] after checking skew. Attributes that change are Type 2 and joined on the business date. Balances are taken at period end, and ratios come from stored parts. I check the result by reconciling row counts and control totals against the source.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.