Star vs. Snowflake

Difficulty: Intermediate

Question

What is the difference between a star schema and a snowflake schema in a data warehouse, and when would you choose each?

Answer

A star schema has one central fact table joined directly to flat, denormalized dimension tables, so every dimension is one join away. A snowflake schema normalizes those dimensions into sub-tables (for example product to category to department), which saves some storage and removes duplication but adds more joins to every query. Most modern warehouses default to the star schema because it is simpler to query and faster to aggregate.

Facts and dimensions first

Both designs come from dimensional modeling (Ralph Kimball's approach). The building blocks are the same:

  • Fact table: one row per business event at a fixed grain, holding numeric measures and foreign keys. Example: fact_orders with one row per order line at Swiggy, storing quantity, amount_paise, delivery_minutes.
  • Dimension tables: the descriptive context you filter and group by, such as dim_date, dim_restaurant, dim_customer, dim_city.

The only real difference between the two schemas is how the dimension tables are shaped.

How the two shapes differ

In a star, dim_restaurant holds everything about a restaurant in one wide row: name, cuisine, city name, state name, zone. City and state values repeat across thousands of restaurants, and that is accepted on purpose.

In a snowflake, dim_restaurant stores only a city_key, which points to dim_city, which points to dim_state. Each attribute lives in exactly one place, like a 3NF OLTP design.

AspectStar schemaSnowflake schema
Dimension designDenormalized, wideNormalized into sub-dimensions
Joins per queryFact plus one join per dimensionExtra joins through dimension hierarchies
Query complexitySimple, BI-tool friendlyMore SQL, more room for mistakes
StorageSome repetition in dimensionsSlightly less repetition
Dimension updatesChange many rows if an attribute changesChange one row in the sub-dimension
Typical useDefault for reporting and BIVery large or shared hierarchies, strict governance

Why star usually wins today

Dimensions are tiny compared to facts. A fact table may hold billions of rows while dim_city has a few thousand, so the storage saved by snowflaking dimensions is negligible. Columnar warehouses such as BigQuery, Redshift, Snowflake (the product) and ClickHouse also compress repeated strings very well, which shrinks the storage argument further.

Meanwhile, every extra join costs planning time and makes the model harder for analysts and BI tools like Power BI, Looker or Metabase to use. Kimball's guidance is to prefer star and snowflake only when there is a clear reason.

When snowflaking makes sense

  • A hierarchy is shared by many dimensions, such as a geography table used by customers, restaurants and warehouses.
  • A dimension is huge and has a low-cardinality subset that changes often (sometimes split out as an "outrigger").
  • Governance requires one authoritative copy of reference data.
  • The warehouse is row-based and storage is genuinely constrained.

Common mistakes

  • Confusing the snowflake schema with Snowflake the cloud warehouse. You can build a star schema in Snowflake.
  • Not declaring the grain of the fact table before designing dimensions.
  • Snowflaking by habit because "normalization is good". The OLTP rules for avoiding update anomalies matter less in a warehouse that is reloaded by ETL.
  • Forgetting slowly changing dimensions (SCD Type 2) when attributes like a customer's city change over time.
Star vs snowflake for one dimension. The fact table is identical; only the restaurant dimension is shaped differently.
Star schemaSnowflake schema
Restaurant dimensionOne wide dim_restaurant tabledim_restaurant plus dim_city plus dim_state
Revenue by state queryFact joins one dimensionFact joins three tables in a chain
Rename a stateUpdate many restaurant rowsUpdate one row in dim_state
Who prefers itAnalysts and BI toolsData modelers guarding reference data

Code examples

Star schema query: revenue by state and month

-- Star: city and state live directly on dim_restaurant
SELECT d.year_month,
       r.state_name,
       SUM(f.amount_paise) / 100.0 AS revenue_rupees
FROM fact_orders f
JOIN dim_date d       ON d.date_key = f.date_key
JOIN dim_restaurant r ON r.restaurant_key = f.restaurant_key
GROUP BY d.year_month, r.state_name;

Each dimension is one join from the fact table, which is easy for both the optimizer and humans to read.

Same query on a snowflake schema

-- Snowflake: restaurant -> city -> state
SELECT d.year_month,
       s.state_name,
       SUM(f.amount_paise) / 100.0 AS revenue_rupees
FROM fact_orders f
JOIN dim_date d       ON d.date_key = f.date_key
JOIN dim_restaurant r ON r.restaurant_key = f.restaurant_key
JOIN dim_city c       ON c.city_key = r.city_key
JOIN dim_state s      ON s.state_key = c.state_key
GROUP BY d.year_month, s.state_name;

Two more joins appear just to reach the state name. Multiply that across every report and the cost in complexity is clear.

Key points

  • Both schemas share the same fact table; they differ only in how dimensions are normalized.
  • Star: denormalized dimensions, fewer joins, simpler BI. Snowflake: normalized dimensions, more joins.
  • Dimensions are small relative to facts, so snowflaking rarely saves meaningful storage.
  • Columnar compression in modern warehouses weakens the storage argument for snowflaking further.
  • Always define the fact table grain first, then design dimensions around it.

Common follow-up questions

  • What is the grain of a fact table and why must it be declared first?
  • How do you handle a customer changing city in a dimension (SCD Type 1 vs Type 2)?
  • What is a galaxy or fact constellation schema?
  • How does a star schema compare to a single wide denormalized table (one big table) in BigQuery?

Interview tips

  • Start with facts vs dimensions before contrasting the shapes; it shows you understand dimensional modeling, not just the names.
  • Say clearly that star is the usual default and give a concrete reason to snowflake, rather than presenting them as equal choices.
  • Clarify the Snowflake product vs snowflake schema distinction if the interviewer mixes them up; it is a common trap.

Concepts covered

Star Schema, Snowflake Schema, Fact Table, Dimension Table, Dimensional Modeling

More Database Design questions