Difficulty: Intermediate
What is the difference between a star schema and a snowflake schema in a data warehouse, and when would you choose each?
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.
Both designs come from dimensional modeling (Ralph Kimball's approach). The building blocks are the same:
fact_orders with one row per order line at Swiggy, storing quantity, amount_paise, delivery_minutes.dim_date, dim_restaurant, dim_customer, dim_city.The only real difference between the two schemas is how the dimension tables are shaped.
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.
| Aspect | Star schema | Snowflake schema |
|---|---|---|
| Dimension design | Denormalized, wide | Normalized into sub-dimensions |
| Joins per query | Fact plus one join per dimension | Extra joins through dimension hierarchies |
| Query complexity | Simple, BI-tool friendly | More SQL, more room for mistakes |
| Storage | Some repetition in dimensions | Slightly less repetition |
| Dimension updates | Change many rows if an attribute changes | Change one row in the sub-dimension |
| Typical use | Default for reporting and BI | Very large or shared hierarchies, strict governance |
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.
| Star schema | Snowflake schema | |
|---|---|---|
| Restaurant dimension | One wide dim_restaurant table | dim_restaurant plus dim_city plus dim_state |
| Revenue by state query | Fact joins one dimension | Fact joins three tables in a chain |
| Rename a state | Update many restaurant rows | Update one row in dim_state |
| Who prefers it | Analysts and BI tools | Data modelers guarding reference data |
-- 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.
-- 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.
Star Schema, Snowflake Schema, Fact Table, Dimension Table, Dimensional Modeling