Comparison
Fan trapvsGrain
Fan trap
you joined two fact tables at different grains and every revenue figure quietly doubled.
A join that multiplies rows because one side has several matches per key, inflating any measure summed afterwards. It is grain error made visible, and it is the single most common way a correct-looking SQL query returns a wrong number. The safe patterns are to aggregate one side to the join grain first, or to keep the two measures in separate queries and union them, rather than trusting a distinct.
Full entry →Grain
someone asked what one row means and three people in the room gave three different answers.
The precise meaning of a single row in a table, stated as a sentence: one row per order line per day, one row per session. Declaring it before anything else is the single most load-bearing habit in modelling, because every join, every sum and every duplicate bug is a grain question in disguise. A table whose grain nobody can state will, given time, be joined at the wrong level and quietly double a number.
Full entry →