Solve “Departments with more than three people”

Free. Runs in your browser, no install.

Data modeling · Extra High-Value

Grain vs granularity

Easygraingranularityaggregationmodeling

Interview question

What is the difference between grain and granularity?

How to answer

The short answer

In practice, interviewers often use grain and granularity interchangeably (both ask "how detailed is 1 row?"), but you can draw a clean distinction.

Grain (dimensional modeling term)

The precise declaration of what one fact row represents. Example: "1 row per order line" or "1 row per customer per day."

Granularity (more general)

How fine or coarse the data is along some axis (time, entity, location). Examples: hourly vs daily vs monthly; user-level vs country-level.

Output
Same process, different granularity:
  clicks per event     (fine)
  clicks per user/day  (coarser)
  clicks per country/day (coarser still)

Grain statement for a table picks ONE of these intentionally.

How to answer in an interview

> "Grain is the one-sentence definition of a row. Granularity is how fine that detail is. I pick an atomic grain for the fact, then build coarser aggregates as rollups."

Watch-out

Changing granularity without changing the model docs is how double-counting starts. Always restate grain when you aggregate.