Chapter 1 · Practice 2 of 4
Declare the grain in one sentence and keep every row at that grain
Why it matters
Write the grain as a sentence before any SQL: "one row per order line", "one row per product per day". Microsoft's fact table guidance explains that the values of the dimension keys set the granularity: a targets table whose date key always holds the first day of a month is at month level, even though the column is a date. Every row must follow the same rule.
A grain statement settles arguments early:
| Table | Grain |
|---|---|
fct_order_lines | One row per order line |
fct_daily_inventory | One row per product per warehouse per day |
fct_sales_targets | One row per salesperson per quarter |
If a requirement needs a different level of detail, it usually needs a different fact table, not extra rows in the existing one. Put the grain sentence in the model's description so everyone downstream can read it.
Avoid
- Adding summary rows such as "monthly total" to a table of individual events