intermediatedata-warehousing

Star and Snowflake Schema

How you lay out tables in a warehouse so analysts can actually query them.

Key Points

What it is

Star and snowflake schemas are ways of organizing tables in a data warehouse for analytical queries. Both have a central fact table surrounded by dimension tables. The difference is whether dimension tables are normalized (snowflake) or denormalized (star).

Why it exists

Normalized relational schemas (3NF) are great for transactions but painful for analytics. A simple business question like 'total sales by product category per quarter' might need 10 joins on a normalized schema. Star schema deliberately denormalizes so that most analytical queries need only one or two joins — fast, readable, easy.

Intuition

Imagine a spreadsheet where each row is a sale. The row has: sale amount, date, which customer, which product, which store. That's your fact table. But 'customer' is just an ID — the actual customer details (name, city, segment) live in a customer dimension table. 'Product' ID links to product name, category, supplier. Star schema: customer dimension has all customer info in one flat table. Category is just a column in the product table. Snowflake schema: product dimension links to a separate category table, which links to a department table. More normalized, more joins.

Example

Star schema: fact_sales(sale_id, date_id, customer_id, product_id, amount). dim_customer(customer_id, name, city, segment). dim_product(product_id, name, category, brand). dim_date(date_id, date, month, quarter, year). Snowflake variant: dim_product now only has (product_id, name, category_id). A separate dim_category(category_id, category_name, department_id) table. Another dim_department(department_id, department_name) table.

Star is simpler and faster to query. Snowflake is cleaner and avoids repeating 'Electronics' across every row in the product table. In practice most warehouses use star or a light hybrid.

When to use

Common mistakes

Notes

In practice

When you pull data from a warehouse for analysis, you're almost certainly working with a star or snowflake schema. Knowing the structure helps you write correct queries, understand why certain columns live in certain tables, and build models in tools like dbt.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

etl-pipelinesolap-vs-oltpnormalization
Chirp at me!