“Explain star schema vs snowflake schema” is one of the most common data warehouse questions in data engineering, ETL and BI interviews. You will hear it at service companies, product companies and banks. The good news: the idea is simple once you see a small example.

In this guide we will build both schemas for a small online shop, write the SQL queries, look at the same join in PySpark, and finish with interview questions. Let’s break it down in simple words.
Quick summary: star schema vs snowflake schema
- Star schema: one central fact table joined directly to flat (denormalized) dimension tables. Fewer joins, faster and easier queries.
- Snowflake schema: the same fact table, but dimensions are split (normalized) into smaller related tables. Less repeated data, but more joins.
- Most modern teams start with a star schema. Microsoft’s Fabric training says to start with a star schema unless you have a specific reason not to.
First, what are fact and dimension tables? (Snowflake schema)
Every dimensional model has two kinds of tables.
A fact table stores events or measurements. Think of every sale, every payment or every website click. It has numbers you add up (quantity, amount) and key columns that point to dimensions. Fact tables usually have many rows and keep growing every day.
A dimension table stores the descriptive details: who, what, where and when. Customer name, product category, store city and calendar date all live in dimensions. Dimensions are used to filter and group the facts, and they are usually much smaller.
Simple way to remember: facts are the numbers, dimensions are the context around the numbers.
What is a star schema? (Snowflake schema)
In a star schema, the fact table sits in the middle and every dimension table connects to it directly. If you draw it, it looks like a star with the fact table at the centre.
Each dimension is denormalized. That means all its details are kept in one wide table. For example, dim_product holds the product name, sub-category and category together, even if the category name repeats for thousands of products.
Here is a small star schema for an online shop:
-- Dimension: product (flat, everything in one table)
CREATE TABLE dim_product (
product_key INT PRIMARY KEY, -- surrogate key
product_id VARCHAR(20), -- business key from source
product_name VARCHAR(100),
subcategory VARCHAR(50),
category VARCHAR(50)
);
-- Dimension: date
CREATE TABLE dim_date (
date_key INT PRIMARY KEY, -- e.g. 20261202
full_date DATE,
month_name VARCHAR(10),
year_num INT
);
-- Fact: one row per order line
CREATE TABLE fact_sales (
date_key INT REFERENCES dim_date(date_key),
product_key INT REFERENCES dim_product(product_key),
customer_key INT,
quantity INT,
sales_amount DECIMAL(12,2)
);Notice the surrogate key (product_key). It is a simple integer created inside the warehouse, not taken from the source system. It keeps joins fast and lets you store history, for example in SCD Type 2.
Now a typical report, “total sales by category for 2026”, needs only two joins:
SELECT p.category,
SUM(f.sales_amount) AS total_sales
FROM fact_sales f
JOIN dim_product p ON f.product_key = p.product_key
JOIN dim_date d ON f.date_key = d.date_key
WHERE d.year_num = 2026
GROUP BY p.category
ORDER BY total_sales DESC;What is a snowflake schema?
A snowflake schema starts from the same star, but some dimensions are normalized. Repeating details are moved into their own tables. Product points to sub-category, and sub-category points to category. When you draw it, the branches spread out like a snowflake.
CREATE TABLE dim_category (
category_key INT PRIMARY KEY,
category_name VARCHAR(50)
);
CREATE TABLE dim_subcategory (
subcategory_key INT PRIMARY KEY,
subcategory_name VARCHAR(50),
category_key INT REFERENCES dim_category(category_key)
);
CREATE TABLE dim_product_sf (
product_key INT PRIMARY KEY,
product_name VARCHAR(100),
subcategory_key INT REFERENCES dim_subcategory(subcategory_key)
);The category name is now stored only once. But look at the same “sales by category” report. It needs more joins:
SELECT c.category_name,
SUM(f.sales_amount) AS total_sales
FROM fact_sales f
JOIN dim_product_sf p ON f.product_key = p.product_key
JOIN dim_subcategory s ON p.subcategory_key = s.subcategory_key
JOIN dim_category c ON s.category_key = c.category_key
JOIN dim_date d ON f.date_key = d.date_key
WHERE d.year_num = 2026
GROUP BY c.category_name
ORDER BY total_sales DESC;Four joins instead of two, for the same answer. On big data, every extra join costs time, and the SQL also becomes harder for analysts to write.
Star schema vs snowflake schema: side-by-side comparison
- Structure: star has flat dimensions linked straight to the fact; snowflake splits dimensions into many linked tables.
- Normalization: star dimensions are denormalized; snowflake dimensions are normalized (often to third normal form).
- Joins: star needs fewer joins; snowflake needs more.
- Query speed: star is usually faster for reporting; snowflake can be slower because of the extra joins.
- Storage: star repeats some text values; snowflake saves some space in very large dimensions.
- Ease of use: star is easier for BI users and tools like Power BI; snowflake is harder to understand.
- Maintenance: in a snowflake, changing a category name means updating one row; in a star, the same change touches many rows.
Star schema in PySpark: a quick example (Snowflake schema)
In Spark and Databricks, a star schema works very well because dimension tables are small. Spark can send a small dimension to every executor with a broadcast join and avoid shuffling the big fact table.
from pyspark.sql import functions as F
fact_sales = spark.table("fact_sales")
dim_product = spark.table("dim_product")
dim_date = spark.table("dim_date")
result = (
fact_sales
.join(F.broadcast(dim_product), "product_key")
.join(F.broadcast(dim_date), "date_key")
.filter(F.col("year_num") == 2026)
.groupBy("category")
.agg(F.sum("sales_amount").alias("total_sales"))
.orderBy(F.col("total_sales").desc())
)
result.show()Spark also broadcasts small tables on its own when they are below the spark.sql.autoBroadcastJoinThreshold setting (10 MB by default). The explicit broadcast() hint just makes your intention clear.
When should you use a snowflake schema?
A star schema is the default choice, but snowflaking still has valid use cases. Microsoft’s Fabric training lists situations like these:
- A dimension is very large and saving storage matters more than query speed.
- Some facts are stored at a higher level. For example, sales targets are set per sub-category, while actual sales are per product.
- You need to track history of changes at a higher level, such as category changes.
Even then, many teams keep a snowflake in the core warehouse but expose a flat view to reporting tools. Microsoft’s Power BI guidance says a single denormalized dimension table is generally better than several snowflake tables inside a Power BI model.
Common interview traps (Snowflake schema)
- “Is snowflake schema related to Snowflake the database?” No. The snowflake schema is a modeling pattern. You can build a star schema inside the Snowflake data cloud too.
- “Which is more normalized?” Snowflake. Star dimensions are denormalized on purpose.
- “Why use surrogate keys?” Integer keys are fast to join, protect you from source key changes, and allow multiple versions of the same customer for history.
- “What is a galaxy schema?” Also called a fact constellation: two or more fact tables (for example, sales and returns) that share the same dimensions, such as date and product.
Key takeaways (Snowflake schema)
- Fact tables store numeric events; dimension tables store descriptive context.
- Star schema = fact table plus flat dimensions. Fewer joins, faster queries, easier for users.
- Snowflake schema = dimensions split into normalized sub-tables. Less duplication, more joins.
- Start with a star schema; use snowflaking only for a clear reason such as very large dimensions or facts at different levels.
- In Spark, small star-schema dimensions pair nicely with broadcast joins.
FAQ (Snowflake schema)
Which is faster, star schema or snowflake schema?
For most reporting queries, a star schema is faster because it needs fewer joins. Actual speed also depends on the engine, indexes or clustering, and data size.
Does a star schema follow normalization?
Not fully. Dimensions are kept denormalized on purpose to make reads simple. The fact table itself is usually narrow and holds keys plus numbers.
Can one data warehouse use both schemas?
Yes. Many warehouses have mostly star-shaped dimensions with one or two snowflaked dimensions where it makes sense. This mix is common in real projects.
What is the grain of a fact table?
The grain is what one row means, for example “one row per order line”. Interviewers love this question, so always state the grain before you design the fact table.
Is star schema still used in lakehouses like Databricks?
Yes. Databricks has published guides on implementing star schemas with Delta Lake, including tips like clustering fact tables on the keys of large dimensions.
Related reading: SQL window functions interview guide, SCD Type 2 explained and broadcast join in PySpark.
Related reading: Remove Duplicates in PySpark and SQL: The Simple Interview Guide · Small Files Problem in Spark and Delta Lake: The Simple Interview Guide
Sources
- Microsoft Learn – Understand star schema and the importance for Power BI
- Microsoft Learn (Fabric training) – Describe dimensional schema types
- Kimball Group – Star Schemas and OLAP Cubes
- Databricks Blog – Five simple steps for implementing a star schema in Databricks with Delta Lake
- Apache Spark docs – Performance tuning (autoBroadcastJoinThreshold)




