Star Schema: Definition, Fact and Dimension Tables
Quick answer
What a star schema is, how fact and dimension tables fit together, a worked SQL query with sample output, and when to choose it over a normalised table.
A star schema is a way of laying out data in a warehouse: one central fact table that records events, such as sales, linked to surrounding dimension tables that describe them, such as product, date and city. Drawn on paper, the fact table sits in the middle and the dimensions radiate out like points of a star.
Key takeaways
- A star schema has one fact table (events and numbers) and several dimension tables (descriptive context).
- Dimension tables are kept flat and denormalised, so a report needs only one join per dimension.
- It suits reporting questions of the form "measure by attribute", such as revenue by city and month.
- It is a poor fit for the transactional tables an app writes to all day.
On this page:
- What a star schema means
- How a star schema works, with a query
- Where star schemas are used
- Common mistakes and confusions
- Related terms
- Frequently asked questions
| Term | What it is | Typical use |
|---|---|---|
| Star schema | One fact table joined directly to flat dimension tables | Reporting and BI |
| Snowflake schema | A star where dimensions are split into further linked tables | Saving storage, avoiding repeated values |
| Normalised (3NF) model | Data split into many small tables with no repeated facts | Apps that insert and update rows |
| Flat or wide table | Everything in one big table | Quick one-off analysis |
What does a star schema mean?
It means you classify every table as either a fact table or a dimension table. According to Microsoft Learn, a star schema is a mature modelling approach widely adopted by relational data warehouses, and it requires modellers to classify their model tables as either dimension or fact.
The Kimball Group describes star schemas as fact tables linked to associated dimension tables. Microsoft Learn adds that dimension tables describe business entities, the things you model, while fact tables store observations or events such as sales orders, stock balances or temperatures.
A simple picture helps. A fact table is the cash-register log: one row per sale, mostly keys and numbers. Dimension tables are lookup cards that say which product, which store and which date. Kimball Group says dimensional models divide data into measurements and the who, what, where, when, why and how descriptive context.
How does a star schema work?
The fact table holds a key column for each dimension plus numeric measures. Microsoft Learn describes it as dimension key columns that relate to dimension tables, and numeric measure columns. To answer a question, you join the fact table to the dimensions you need and group by their attributes.
Here is a small illustrative example with made-up numbers. The table fact_sales has six rows, dim_date has a month column and dim_product has a category column.
SELECT d.month, p.category, SUM(f.amount) AS revenue
FROM fact_sales AS f
JOIN dim_date AS d ON f.date_key = d.date_key
JOIN dim_product AS p ON f.product_key = p.product_key
GROUP BY d.month, p.category
ORDER BY d.month, p.category;With the illustrative data, the query could return four rows:
| month | category | revenue |
|---|---|---|
| 2026-01 | Bags | 800 |
| 2026-01 | Stationery | 350 |
| 2026-02 | Bags | 1000 |
| 2026-02 | Stationery | 250 |
Adding a new question, such as revenue by city, means adding one more dimension and one more join. The fact table does not change shape. If you are rusty on the joins themselves, read SQL joins explained with examples.
Where are star schemas used?
They are used wherever people slice numbers by descriptive attributes: data warehouses, dashboards and BI tools. Microsoft Learn's guidance is written for Power BI models.
An illustrative Indian example: a quick-commerce company keeps one row per order line in fact_orders, with dimensions for city, dark store and date. An analyst can then ask for orders by city and week without touching the app's live database. Microsoft Learn notes that a date dimension is the most consistent table in a star schema.
Decision rule: choose a star schema when the question is "measure by attribute". Keep the table normalised when an application writes the data. A star usually sits downstream, loaded from those source tables. Our guide to a data warehouse covers that loading step.
What are the common mistakes?
- Mixing fact and dimension columns in one table. Microsoft Learn advises avoiding mixing the two types in a single table.
- Treating denormalised as a flaw. Microsoft Learn calls a sales table denormalised if it stores product details beyond the key. In a star, product details belong in the dimension, which stays denormalised on purpose.
- Forgetting size differences. Per Microsoft Learn, dimension tables generally have a relatively small number of rows, while fact tables can be large and keep growing.
Which terms are related?
A snowflake schema splits dimensions into further tables. Dimensional modelling is the wider method, covered on the Kimball Group site. For query practice, see SQL window functions and creating SQL tables.
Next step
Sketch a star for something you know, such as a food-delivery order. List the one fact table, three dimensions and the measures. Then build it in SQL, and try the ideas in SQL projects for data analysts.
Frequently asked questions
What is a star schema in data warehousing?
A star schema is a layout with one central fact table linked to several dimension tables. The fact table stores events and numeric measures, and the dimensions hold descriptive context such as product, date and location. It is built for reporting.
What is the difference between a fact table and a dimension table?
A fact table stores observations or events, such as sales orders, along with numeric measures and dimension keys. A dimension table describes business entities, such as products or customers. Dimensions generally have fewer rows than facts.
Why is a star schema denormalised?
Dimension tables keep their descriptive attributes together in one flat table rather than spreading them across many linked tables. This keeps queries to one join per dimension. The trade-off is some repeated values, which is accepted for reporting.
What is a snowflake schema and how does it differ?
A snowflake schema starts from a star but splits dimension tables into further linked tables. This reduces repeated values at the cost of extra joins. A star keeps each dimension as a single flat table.
Where is a star schema used?
It is used in data warehouses and BI tools, including Power BI models, where users total numbers by descriptive attributes such as city, month or product category.
When should I not use a star schema?
Avoid it for the tables an application writes to constantly. Keep those normalised, and build a star downstream for reporting.