How to Choose Between Star and Snowflake Schemas in BigQuery

Galaxy Glossary

Which is better for BigQuery—star schema or snowflake schema?

A star schema keeps dimensions denormalized while a snowflake schema normalizes them; the right choice affects query speed, storage cost, and maintenance in BigQuery.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

When should I use a star schema in BigQuery?

Pick a star schema when analytics speed matters more than storage. Star keeps each dimension in a single, wide table, reducing joins. BigQuery’s columnar storage compresses repeated dimension values, so denormalization rarely explodes cost.

When is a snowflake schema better?

Choose a snowflake schema when dimensions change frequently, contain many low-cardinality attributes, or are reused by multiple fact tables. Normalizing dimensions cuts maintenance time and avoids duplicate updates.

How do I model an ecommerce dataset as a star schema?

Create one fact table (Orders) and one dimension table per business entity—Customers, Products, Date. The Orders fact stores foreign keys to each dimension plus measures such as total_amount.

How do I model the same dataset as a snowflake schema?

Break large dimensions into subdimensions. For example, split the Products dimension into Product, Category, and Supplier tables. The Orders fact references Product; Product references Category and Supplier, forming a chain of smaller tables.

Which schema queries faster in BigQuery?

Star schemas usually scan fewer tables, so BigQuery can prune columns quickly and parallelize work, giving lower latency. Snowflake schemas may add shuffle steps for extra joins.

Which schema costs less?

Storage: snowflake wins by avoiding repeated dimension data. Query: star wins by reading fewer tables. For most workloads, BigQuery’s compressed storage makes the cost gap small.

Best practices for star vs snowflake in BigQuery

1. Partition and cluster the fact table by date and common filters.
2. Use surrogate integer keys for joins; avoid strings.
3. Materialize high-use snowflake joins into views or scheduled tables.
4. Revisit schema choice as data volume and query patterns evolve.

Why How to Choose Between Star and Snowflake Schemas in BigQuery is important

How to Choose Between Star and Snowflake Schemas in BigQuery Example Usage


-- Star schema query: total revenue by product name
SELECT p.name, SUM(o.total_amount) AS revenue
FROM ecommerce.Orders o
JOIN ecommerce.Products p ON p.id = o.product_id
WHERE o.order_date BETWEEN '2024-01-01' AND '2024-03-31'
GROUP BY p.name
ORDER BY revenue DESC;

How to Choose Between Star and Snowflake Schemas in BigQuery Syntax


-- Star schema example
CREATE TABLE ecommerce.Orders (
    id INT64,
    order_date DATE,
    customer_id INT64,
    product_id INT64,
    quantity INT64,
    total_amount NUMERIC
) PARTITION BY order_date CLUSTER BY customer_id;

CREATE TABLE ecommerce.Customers (
    id INT64,
    name STRING,
    email STRING,
    created_at TIMESTAMP
);

CREATE TABLE ecommerce.Products (
    id INT64,
    name STRING,
    price NUMERIC,
    stock INT64
);

-- Snowflake variant: normalize Products
CREATE TABLE ecommerce.Categories (
    id INT64,
    name STRING
);

CREATE TABLE ecommerce.Suppliers (
    id INT64,
    name STRING,
    country STRING
);

CREATE TABLE ecommerce.Product (
    id INT64,
    name STRING,
    category_id INT64,
    supplier_id INT64,
    price NUMERIC,
    stock INT64
);

Common Mistakes

Frequently Asked Questions (FAQs)

Does denormalization inflate BigQuery storage cost?

BigQuery’s columnar compression keeps repeated dimension values small. For most cases, the cost increase is negligible compared to the performance gain.

Can I mix star and snowflake designs?

Yes. Many teams keep high-use dimensions denormalized (star) and less-used dimensions normalized (snowflake), gaining speed without sacrificing maintainability.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.