Wednesday, July 11, 2018

What is grain of a table in data warehousing

In simple terms grain is the lowest level till which you could identify the data in a table.
For example: If you have table which holds the stock inventory and table holds:

  1. One record for each day of the stock : Than the grain would be one day
  2. One record for each hour : than the grain of the table would be hour
  3. One record for each week : than the grain of the week would be week.



How does grain impacts the data warehouse:
It is important that while designeing the databse we design till the lowest grain for which we business needs to analyse or report.
With example above, If your Stock inventory table has grain of day you can easily calculate weekly stock but viceversa is not true.

Similarly, grain of related tables(Facts and Dims) should complement each other. For eg if Fact_Stock_Inventory holds data for each hour and Dim_DateTime has a grain of a day, it will generate distorted results.

No comments:

Post a Comment

If you liked the post, please share it.
Subscribe to your email and receive new articles on your email