Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the Grain in the context of DW

According to The Data Warehouse Toolkit by Kimball

"The grain must be declared before choosing dimensions
or facts because every candidate dimension or fact must be consistent with the grain."

I'm so confused about this concept .Could some one illustrate what's the meaning of Grain giving an analogy or metaphor in real life to clarify the concept .

like image 821
Anyname Donotcare Avatar asked Aug 27 '16 12:08

Anyname Donotcare


2 Answers

Some examples:

  • "The sales table has a grain of DAY, STORE, PRODUCT"
  • "The sales table has a grain of DAY, STORE, PRODUCT, CUSTOMER"
  • "The sales table has a grain of HOUR, STORE, CUSTOMER"
  • "The sales summary table has a grain of DAY, STORE, PRODUCT_CLASS"

Hence the time dimension must support HOUR and DAY, and the product dimension must support PRODUCT and PRODUCT_CLASS.

like image 91
David Aldridge Avatar answered Oct 14 '22 22:10

David Aldridge


The grain (or granularity of the fact) refers to the 'level' at which you're taking a measurement. A fact table describes a measurement taken of a business process, so the best way to describe the grain is to describe what you get for each row. The classic example for a supermarket checkout is 'one row for every beep/scan'. This is better than saying 'one row for every day, product and store' (i.e. naming the dimensions) because it grounds it in reality.

The grain/level element is that you might be storing a row at a level of product, or you might be storing it at some grouping of products. This matters as it will determine whether you can use the product-level dimension or the group-level dimension with it.

like image 25
Rich Avatar answered Oct 14 '22 20:10

Rich