Facts and dimensions
Data Modelling · 12 questions
Short notes
Key idea
Analytical models split data into facts (measurable events: sales, clicks, payments) and dimensions (the context you slice by: who, what, where, when).
Syntax
- Fact table: foreign keys to dimensions + numeric measures (amount, qty). Long and narrow, grows fast.
- Dimension table: a key + descriptive attributes (customer name, city, segment). Short and wide.
- Measures: additive (amount), semi-additive (account balance: not over time), non-additive (ratios: compute from parts).
- Date dimension: one row per day with year, month, weekday, holiday flags.
Example
fact_sales(date_key, customer_key, product_key, store_key, qty, amount) with dim_date, dim_customer, dim_product, dim_store. "Revenue by city by month" = join fact to dim_store and dim_date, group, sum amount.
Traps
- Storing ratios in the fact table; store the numerator and denominator.
- Summing a balance across days double counts; take the closing value.
- Text attributes in the fact table bloat it; move them to a dimension.
- No date dimension means every report re-derives months and holidays.
Want the full lesson with step-by-step examples, a project and a certificate? Data Modelling course, ₹120 →
Questions
5 free questions- Question 1easy
Which of these belongs in a dimension table?
- Question 2medium
A fact table stores each product's stock level every day. What's wrong with summing stock across a month?
- Question 3medium
You need conversion rate by city and month. What should the fact table store?
- Question 4hard
In fact_sales, order_id has no other attributes worth a table. Where should it live?
- Question 5easy
Which columns belong in dim_product?
Facts and dimensions
Facts and dimensions
Facts and dimensions
Facts and dimensions
Facts and dimensions
7 more questions on this topic, with hints, and tests
Sign up free for 21 days of every question and test.