Data Modeling Best Practices

Chapter 1 · Practice 2 of 4

Declare the grain in one sentence and keep every row at that grain

From Start from the business process and the 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:

TableGrain
fct_order_linesOne row per order line
fct_daily_inventoryOne row per product per warehouse per day
fct_sales_targetsOne 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