Loading section...

Defining the Grain

Concepts: dmGrainDefinition

The grain is the most important decision in dimensional modeling. It defines what one row in the fact table represents. 'One row per order line item.' 'One row per click event.' 'One row per daily account balance.' Everything else follows from this: which dimensions make sense, which measures are valid, which queries produce correct results. How to State the Grain A grain statement is precise enough that another engineer can write a uniqueness test against it. 'One row per order' is vague. 'One row per order line item, unique on (order_id, line_item_seq)' is precise. The grain statement names the unit of analysis AND the columns that enforce uniqueness. Why Grain Matters Getting the grain wrong does not produce an error message. It produces wrong numbers that look right. If you define the