This sample is a retail star schema: a central fact_sales table records every sold order line, and four dimension tables (date, product, store, customer) describe the who, what, where and when. It is the standard shape for a data warehouse or BI data mart.
1. The Diagram
A star schema has one fact table surrounded by denormalised dimension tables. It looks like a star, hence the name.
Start in the centre with fact_sales (yellow). Its grain is one row per product per order line; every design choice follows from that sentence.
Four foreign keys point outward to the dimensions. They are integer surrogate keys, not source system IDs, so history and late-arriving data can be handled.
The numeric columns are measures. quantity and the amounts are additive: they can be summed across any dimension.
order_number is a degenerate dimension (DD): a useful label with no attributes of its own, so it lives on the fact.
dim_date holds one row per day with calendar and fiscal attributes, so reports never compute quarters in SQL.
dim_customer has valid_from, valid_to and is_current: a slowly changing dimension type 2 that keeps past cities and segments.
Each dimension-to-fact line is one-to-many: one product row matches many sales rows. A query filters dimensions and sums the fact.
2. How to Read It
Star schemas reuse crow's foot ER notation, with a colour or label to separate facts from dimensions. Some teams draw the fact table in the middle and omit columns, showing only names and the grain; that is fine for discussions but the column version is what engineers build from.
3. Variant: Snowflaked Dimension
In a snowflake schema the product dimension is normalised into product, subcategory and category tables. It removes repeated category names, but every report now needs extra joins and BI tools struggle more. Most modern columnar warehouses compress repeated strings cheaply, so the flat star is usually preferred.
4. Pros, Cons, and When to Use
Pros
Business users understand it: facts are numbers, dimensions are how you slice them.
Few, predictable joins; fast on columnar warehouses.
Grain and measures are explicit on the page.
Directly supported by BI tools (Power BI, Looker, Tableau).
Conformed dimensions let several stars share date, product and store.
Cons
Denormalised dimensions repeat data and need ETL to keep consistent.
Not suited to transactional writes.
Many-to-many cases (one sale, many promotions) need bridge tables.
Slowly changing dimension logic is not visible without notes.
When to use
Designing data marts and semantic layers for BI.
Explaining a warehouse model to analysts.
When not to use
Operational OLTP schemas (use an ER or logical schema diagram).
Raw integration layers with frequent source change (consider Data Vault).
5. As Diagrams-as-Code
MermaiderDiagram; Mermaid has no layout hint for a star, so it will place tables in rows:
erDiagram
dim_date ||--o{ fact_sales : "date_key"
dim_product ||--o{ fact_sales : "product_key"
dim_store ||--o{ fact_sales : "store_key"
dim_customer ||--o{ fact_sales : "customer_key"
fact_sales {
bigint sales_line_id PK
int date_key FK
int product_key FK
int store_key FK
int customer_key FK
varchar order_number
int quantity
decimal net_amount
}
dim_customer {
int customer_key PK
bigint customer_id
varchar segment
date valid_from
date valid_to
}