Choose star schema for speed and simplicity; choose snowflake schema for storage efficiency and normalized data.
Star schemas denormalize dimension tables for faster joins and simpler SQL. Snowflake schemas normalize dimensions into sub-tables, cutting storage and update anomalies. Pick the model that best balances query speed, maintenance effort, and disk cost.
Star schemas excel in read-heavy analytics where joins dominate runtime.Fewer joins let the planner push down filters and exploit indexes, boosting dashboard speed.
Choose snowflake when dimension data changes often, must avoid duplication, or when storage costs matter. Normalized tables let updates cascade cleanly and reduce disk use.
Create one fact table (Orders) and wide dimension tables (Customers, Products, Calendar).Fact rows hold foreign keys to each dimension.
-- fact
CREATE TABLE Orders (
id SERIAL PRIMARY KEY,
customer_id INT,
product_id INT,
order_date DATE,
total_amount NUMERIC(10,2)
);
-- dimensions
CREATE TABLE Customers (
id SERIAL PRIMARY KEY,
name TEXT,
email TEXT,
created_at TIMESTAMP
);
CREATE TABLE Products (
id SERIAL PRIMARY KEY,
name TEXT,
price NUMERIC(8,2),
stock INT
);
Split low-cardinality attributes into sub-tables.Customers gets a Geography table; Products gets a Category table. Facts still reference leaf dimension tables.
CREATE TABLE Geography (
id SERIAL PRIMARY KEY,
country TEXT,
region TEXT
);
ALTER TABLE Customers ADD COLUMN geography_id INT;
Star queries join fewer tables; snowflake queries add joins for each normalized level. Index foreign keys to keep performance acceptable.
Start star, then snowflake only the high-cardinality or frequently changing dimensions.Measure query plans before and after refactors.
.
Usually, because fewer joins mean fewer lookups. However, bad indexing or huge dimension tables can erase the gain.
Yes. A hybrid approach lets you denormalize hot dimensions while keeping others normalized.
No. The Snowflake platform supports both models; schema design depends on workload, not the engine.