Star Schema vs Snowflake Schema: Differences and a Worked SQL Example
A star schema keeps each dimension in one flat table. A snowflake schema splits it into sub-tables. The same sales data built both ways in PostgreSQL, with the joins and updates each design needs.
On this page · 22 sections
- Star schema vs snowflake schema at a glance
- How each schema stores a dimension
- Star schema
- Snowflake schema
- Worked example: one sales dataset, built both ways
- Build the snowflake schema
- Flatten it into a star schema
- Revenue by department: one join versus three
- Renaming a department: five rows versus one
- What the Kimball Group says about snowflaked dimensions
- When snowflaking a dimension is justified
- The Snowflake data platform is unrelated
- Star and snowflake schemas in a dbt project
- Several fact tables: the galaxy schema
- Common mistakes
- Frequently Asked Questions
- What is the main difference between a star schema and a snowflake schema?
- Is a star schema faster than a snowflake schema?
- Does a snowflake schema save storage?
- When should I use a snowflake schema instead of a star schema?
- Should I use a star schema or a snowflake schema in Power BI?
- Primary sources and further reading
- Topic
- Data Modeling
- Category
- Data Modeling
A star schema keeps each dimension in one denormalized table that joins directly to the fact table. A snowflake schema normalizes dimensions into sub-tables, so the same question needs more joins. Star schema vs snowflake schema is a choice about dimensions only, because the fact table is the same in both. As a default in the star vs snowflake decision, build the star, and snowflake a dimension only when its hierarchy is shared by several dimensions or maintained separately.
Three terms recur below. A fact table stores one row per event with its measurements, such as a sale and its revenue. A dimension table describes what the event involved, such as the product. A hierarchy is a chain of many-to-one relationships inside a dimension, such as product to category to department. Facts and dimensions for beginners covers the first two.
Star schema vs snowflake schema at a glance
| Aspect | Star schema | Snowflake schema |
|---|---|---|
| Dimension structure | One wide, denormalized table per dimension | A base table plus a sub-table for each hierarchy level |
| Joins per query | One per dimension used | One per hierarchy level: three to reach a department in the example below |
| Storage and redundancy | Hierarchy values repeat on every dimension row | Each hierarchy value is stored once |
| Where a hierarchy change is made | On every dimension row that carries the value | On one row of the sub-table |
| Ease of use in BI tools | One table per dimension to pick fields from | More tables and relationships for report authors to navigate |
| When to use | The default for reporting and dashboards | A hierarchy shared by several dimensions, or one maintained separately |
How each schema stores a dimension
Star schema
A star schema is a fact table with dimension tables around it. The Kimball Group describes star schemas as dimensional models built in a relational database, with fact tables linked to dimension tables through primary key and foreign key relationships. Each dimension is denormalized: values are repeated instead of being moved to a table of their own, so every product row carries its category name and department name.
Snowflake schema
A snowflake schema normalizes those hierarchy columns: each value is stored once in its own table and referenced by a key. The product table keeps a category key, the category table keeps a department key, and each department name sits on one row. Drawn as a diagram, the sub-tables branch outward from the fact table, which gives the design its name. Normalization and denormalization explains the technique.
Worked example: one sales dataset, built both ways
Everything below was run on PostgreSQL 16, and the output is what it returned. The designs sit in two PostgreSQL schemas (namespaces) named snowflake and star, so the table names can match.
Build the snowflake schema
Three departments, four categories, eight products, and eight sales:
create schema snowflake;
create table snowflake.dim_department (
department_key int primary key,
department_name text not null
);
create table snowflake.dim_category (
category_key int primary key,
category_name text not null,
department_key int not null references snowflake.dim_department
);
create table snowflake.dim_product (
product_key int primary key,
product_name text not null,
category_key int not null references snowflake.dim_category
);
create table snowflake.fct_sales (
sale_id int primary key,
sale_date date not null,
product_key int not null references snowflake.dim_product,
revenue numeric(10,2) not null
);
insert into snowflake.dim_department values
(1, 'Grocery'), (2, 'Home'), (3, 'Electronics');
insert into snowflake.dim_category values
(10, 'Coffee', 1), (20, 'Kitchen', 2),
(21, 'Bedding', 2), (30, 'Audio', 3);
insert into snowflake.dim_product values
(100, 'Espresso Beans', 10), (101, 'Decaf Pods', 10),
(102, 'Chef Knife', 20), (103, 'Cast Iron Pan', 20),
(104, 'Cutting Board', 20),
(105, 'Duvet Cover', 21), (106, 'Pillow Set', 21),
(107, 'Headphones', 30);
insert into snowflake.fct_sales values
(1, '2026-03-02', 100, 36.00),
(2, '2026-03-02', 102, 89.00),
(3, '2026-03-03', 107, 129.00),
(4, '2026-03-03', 105, 64.50),
(5, '2026-03-04', 101, 41.25),
(6, '2026-03-04', 103, 98.00),
(7, '2026-03-05', 106, 48.00),
(8, '2026-03-05', 104, 27.50);
Flatten it into a star schema
The star's product dimension is the three snowflake tables joined once and saved. The fact table is copied unchanged.
create schema star;
create table star.dim_product as
select
p.product_key,
p.product_name,
c.category_name,
d.department_name
from snowflake.dim_product p
join snowflake.dim_category c on c.category_key = p.category_key
join snowflake.dim_department d on d.department_key = c.department_key;
create table star.fct_sales as
select * from snowflake.fct_sales;
select * from star.dim_product order by product_key;
product_key | product_name | category_name | department_name
-------------+----------------+---------------+-----------------
100 | Espresso Beans | Coffee | Grocery
101 | Decaf Pods | Coffee | Grocery
102 | Chef Knife | Kitchen | Home
103 | Cast Iron Pan | Kitchen | Home
104 | Cutting Board | Kitchen | Home
105 | Duvet Cover | Bedding | Home
106 | Pillow Set | Bedding | Home
107 | Headphones | Audio | Electronics
(8 rows)
Every row now carries its own category and department. A department name is stored on 8 rows here and on 3 rows in snowflake.dim_department.
Revenue by department: one join versus three
The star query joins the fact table to one dimension table:
select d.department_name, sum(f.revenue) as revenue
from star.fct_sales f
join star.dim_product d on d.product_key = f.product_key
group by d.department_name
order by revenue desc;
The snowflake query walks the hierarchy, one join per level:
select d.department_name, sum(f.revenue) as revenue
from snowflake.fct_sales f
join snowflake.dim_product p on p.product_key = f.product_key
join snowflake.dim_category c on c.category_key = p.category_key
join snowflake.dim_department d on d.department_key = c.department_key
group by d.department_name
order by revenue desc;
Both return the same three rows:
department_name | revenue
-----------------+---------
Home | 327.00
Electronics | 129.00
Grocery | 77.25
(3 rows)
The star needs one join and the snowflake needs three, and PostgreSQL's EXPLAIN plans show the same: one hash join against three. On eight rows that says nothing about speed. It shows how much more SQL each report by department carries.
Renaming a department: five rows versus one
The Home department is renamed Home and Garden. Each design needs one UPDATE:
update star.dim_product
set department_name = 'Home and Garden'
where department_name = 'Home';
update snowflake.dim_department
set department_name = 'Home and Garden'
where department_key = 2;
PostgreSQL reported UPDATE 5 for the star, one row per product in the department, and UPDATE 1 for the snowflake. Afterward both revenue queries return Home and Garden with 327.00.
The row count is not the real cost. The risk in the star is an update whose filter misses rows, leaving two spellings of one department and splitting its revenue across two report lines. The snowflake cannot get into that state, because the name exists once. Both statements overwrite the old name. To keep the name that applied when each sale happened, use a Type 2 slowly changing dimension in either design.
What the Kimball Group says about snowflaked dimensions
The Kimball Group's page on snowflaked dimensions defines the pattern the same way: when a hierarchy in a dimension table is normalized, its attributes with few distinct values become secondary tables connected to the base dimension table, and repeating this for every hierarchy produces the multilevel structure called a snowflake. The page says a snowflake represents hierarchical data accurately but should be avoided, because business users find it hard to understand and navigate and it can hurt query performance. It adds that a flattened, denormalized dimension table holds the same information as the snowflaked version. The example shows this: star.dim_product came from the snowflake tables in one query.
Two neighboring pages complete the position. The page on denormalized flattened dimensions tells designers to resist the normalizing habit learned from operational databases and to flatten many-to-one, fixed-depth hierarchies into attributes on the dimension row. The page on outrigger dimensions says a dimension may reference another dimension table, such as a bank account dimension referencing the date the account was opened, and that this is allowed but should be used sparingly.
When snowflaking a dimension is justified
Treat a snowflaked dimension as an exception that needs a reason. Two reasons hold up:
- A hierarchy shared by several dimensions. If customers, stores, and suppliers all roll up to the same city, region, and country, one geography table referenced by all three keeps them consistent.
- A hierarchy maintained separately. If the department list has its own owner, source system, or attributes such as a manager, a department table gives them one place to change.
Storage alone is a weak reason. The repetition is confined to the dimension, and Microsoft's star schema guidance for Power BI notes that dimension tables generally hold relatively few rows while fact tables can hold many and keep growing. Decide one dimension at a time.
The Snowflake data platform is unrelated
Snowflake, the cloud data platform, shares a name with the snowflake schema and nothing else. Snowflake's documentation describes the product as a data platform delivered as a service with its own SQL query engine. A snowflake schema is a way of arranging tables in any relational database: the example above is one in PostgreSQL.
Star and snowflake schemas in a dbt project
In a dbt project, keep the normalized shape in staging models and build the star in the marts layer: a dim_product model that joins the staging models for products, categories, and departments, as the create table ... as statement above does. dbt's documentation says a model materialized as a table is rebuilt on each run, so a department renamed in the source reaches every product row on the next run with no hand-written update. dbt Labs recommends wide, denormalized marts, except in projects that use the dbt Semantic Layer, where it recommends staying as normalized as possible. Structuring a dbt project covers the layers.
To practice, flatten two related tables from the free practice datasets into one dimension.
Several fact tables: the galaxy schema
Both designs above have one fact table. When a second fact table, such as refunds, joins to the same product dimension, the model is called a galaxy schema or fact constellation. The star or snowflake question still applies to each dimension. Designing a warehouse schema from star to galaxy covers that process.
Common mistakes
- Snowflaking by habit. Normalizing is the right instinct in an operational database. In a dimension it adds joins to every query.
- Patching a denormalized attribute by hand. An update that misses rows leaves two values for one thing. Rebuild the flat dimension from normalized source tables instead.
- Joining hierarchy levels on names. A join on
category_namebreaks the day a name changes. Join on keys; see surrogate and natural keys. - Exposing sub-tables to report authors. If you keep sub-tables for maintenance, publish a flattened table or view for reporting.
Frequently Asked Questions
What is the main difference between a star schema and a snowflake schema?
A star schema stores each dimension in one denormalized table joined directly to the fact table. A snowflake schema normalizes a dimension's hierarchies into sub-tables, so reaching a higher level such as department takes one more join per level. The fact table is the same in both.
Is a star schema faster than a snowflake schema?
A snowflake query does more joins for the same answer: three against one in this article's example. The Kimball Group says snowflakes can hurt query performance. How much depends on your database and data volumes, so measure it there.
Does a snowflake schema save storage?
It stores each hierarchy value once: in the example, a department name sits on 3 rows in the snowflake and on 8 rows in the star. The saving is limited to dimension tables, so treat it as a minor factor unless a dimension is very large.
When should I use a snowflake schema instead of a star schema?
Snowflake a dimension when its hierarchy is shared by several dimensions, or when the hierarchy is maintained separately with its own owner, source system, or attributes. Otherwise keep the dimension flat.
Should I use a star schema or a snowflake schema in Power BI?
Microsoft's guidance says Power BI Desktop can either mimic a snowflake dimension with several model tables or combine them into one denormalized table, and that the benefits of a single table generally outweigh those of multiple tables, though the best choice can depend on data volumes and usability requirements. It says keeping the snowflake means more tables to load, longer filter propagation chains, and no hierarchy that spans more than one table.
Primary sources and further reading
- Snowflaked Dimensions, Kimball Group. Defines a snowflaked dimension and advises against it.
- Denormalized Flattened Dimensions, Kimball Group. The advice to flatten fixed-depth hierarchies.
- Outrigger Dimensions, Kimball Group. A dimension that references another dimension.
- Star Schemas and OLAP Cubes, Kimball Group. The definition of a star schema used here.
- Understand star schema and the importance for Power BI, Microsoft Learn. Snowflake dimensions in Power BI, the snowflake shape, and the relative size of dimension and fact tables.
- Materializations, dbt documentation. A table model is rebuilt on each run.
- Marts: Business-defined entities, dbt Labs. Denormalized marts and the dbt Semantic Layer exception.
- Snowflake key concepts and architecture, Snowflake documentation. What the Snowflake product is.
- Fundamentals
Natural Key vs Surrogate Key: Definitions, Examples, and When to Use Each
Learn the differences between surrogate and natural keys in databases. This guide covers their benefits, drawbacks, and when to use each type effectively.
- Data Modeling
Fact Table vs Dimension Table: Differences, Grain, and Examples
Explore the roles of fact and dimension tables in data warehousing. Learn how they work together to enhance data analysis and business insights.
- Data Modeling
Star Schema vs Snowflake Schema: Differences and a Worked SQL Example
A star schema keeps each dimension in one flat table. A snowflake schema splits it into sub-tables. The same sales data built both ways in PostgreSQL, with the joins and updates each design needs.
Drill it in the exercise library.
Portfolio-ready builds on this topic.
- advanced · open →
SQL Survival Challenge: Last City on Earth
Emergency operations analytics: triage supplies, power, and threats to keep the Last City alive.
- advanced · open →
Zombie Virus - Phase 3: The Cure
Cohort & effectiveness analytics: measure a vaccine's impact on infections, survivors, and city resilience.
