TECHNOLOGIESTieInn Technologies

Grain and fact table types

Data Modelling · 11 questions

Short notes

Key idea

The grain is what one row of a fact table means, such as "one product line on one order". Declare it first; every column and every sum depends on it.

Syntax

  • Transaction fact: one row per event (each order line). Most detailed.
  • Periodic snapshot: one row per entity per period (each account's balance each day).
  • Accumulating snapshot: one row per process instance, updated as milestones happen (order placed, packed, shipped, delivered dates).
  • Factless fact: records that something happened, with no measure (attendance).

Example

An order with three products. At order-line grain the fact has 3 rows; the delivery fee belongs to the order, not each line. Putting it on every line triples it in sums; split it across lines or keep a separate order-grain fact.

Traps

  • Mixed grain (some rows per order, some per line) makes every total wrong.
  • Choose the lowest useful grain; you can always roll up, never drill down.
  • Snapshots need closing values, not sums over time.
  • Write the grain in the table's description so nobody guesses.

Want the full lesson with step-by-step examples, a project and a certificate? Data Modelling course, ₹120 →

Questions

5 free questions
5 questions

    Grain and fact table types

  1. Question 1easy

    What is the grain of a fact table?

  2. Grain and fact table types

  3. Question 2hard

    fact_sales is at order-line grain. Someone adds the order's delivery fee (₹40) to every line. An order with 3 lines is summed. What total delivery fee is reported?

  4. Grain and fact table types

  5. Question 3medium

    Finance needs each bank account's closing balance on every month end. Which fact table type?

  6. Grain and fact table types

  7. Question 4medium

    You need to track each loan application through applied, approved, and disbursed dates. Which type?

  8. Grain and fact table types

  9. Question 5medium

    Why prefer storing order lines rather than daily totals per product?

6 more questions on this topic, with hints, and tests

Sign up free for 21 days of every question and test.