Bookmarks

Star schema

A way of organising tables in a data warehouse: a central fact table with numeric measures, surrounded by dimension tables linked by simple relationships.

Also: star model, star join schema

checked 9 Nov

All terms

The classic schema of a relational data warehouse: a fact table in the centre, dimension tables around it — together the picture looks like a star. This layout arose to serve analytics: instead of storing transactions, the business needs to compute sums and groupings quickly — sales by month, region and product.

Facts and dimensions

A fact table stores events and their numeric measures: sales, payments, sensor readings. One row is one event at a given grain, for example a single line item on a receipt. Where possible, its numbers are made additive — they can be freely summed along any dimension: instead of the price, the line amount is stored.

Dimension tables answer the questions “who, what, where, when”: product, store, date, customer. Each contains a surrogate key and the descriptive attributes with which reports filter and group facts. That is why dimensions are deliberately denormalised: one flat product, with category and brand in the same row.

TableContentsNumber of rows
fact_salesdimension keys, line amount, quantity, discountbillions
dim_datedate, year, quarter, month, day of weekthousands
dim_storestore, city, region, typehundreds
dim_productproduct, category, brandtens of thousands

Why a star

There is always just one join, and it is simple: a key in the fact table to a dimension key. A typical analytical query joins the fact table to several dimensions, then filters and groups the data by their attributes — and it is the dimensions that give reports the entry points for this. It is exactly these single-key joins that make the star fast and predictable in query plans.

Ralph Kimball introduced dimensional modelling, the star schema included, into practice in 1996 with the book The Data Warehouse Toolkit.

Star and snowflake

The snowflake schema is a variant with normalised dimensions: a product category is moved into a separate table and linked to the product instead of sitting in its row. The star is the more common choice: as Kimball observed, the benefit of a single flat dimension table usually wins out, and the final choice depends on data volumes and reporting needs.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs