🗄️Star Schema
One fact table in the middle. Each dimension table joins straight to it.
Think of it like
It is like a wheel. The hub is in the middle, and each spoke goes straight out to the rim.
Example
A shop's star has a sales fact table in the middle. Date, shop, product and customer tables sit around it.
Why it matters
It is simple for people and fast for warehouses. Most BI tools are built to read it.
Definition
Example code
sql
SELECT d.month, p.brand, SUM(f.amount)
FROM fact_sales f
JOIN dim_date d ON f.date_key = d.date_key
JOIN dim_product p ON f.product_key = p.product_key
GROUP BY d.month, p.brand;Common mistake
Key takeaways
- 1Fact in the middle. One table of events.
- 2One join each. Dimensions join straight to the fact.
- 3Flat dimensions. Each dimension is one wide table.