Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. Grain vs granularity

Data modeling · Extra High-Value

Grain vs granularity

Easymodel-35
graingranularityaggregationmodeling

Question

What is the difference between grain and granularity?

Solution

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

Grain (dimensional modeling term)

The precise declaration of what one fact row represents. Example: "one row per order line" or "one 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.

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.

PreviousNext