Kimball Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Can a 'fact grain' attribute be null?

3 posters

Go down

Can a 'fact grain' attribute be null? Empty Can a 'fact grain' attribute be null?

Post  nash Sun Feb 12, 2012 10:29 pm

I understand that we build a special value (something "N/A") in each dimension to cater for certain scenarios (and to enforce FK). It makes sense for optional (non-key, non fact-grain) attributes. But is it acceptable for the grain attributes too?

I have a fact table that stores volumes (counts only). It has 5 attributes that define its grain. Now we are adding a new data source, which counts exactly the same volumes for the same concept, but only 4 out of 5 fact grain attributes are applicable to its count fact.
Is ramming this into existing fact table ok (and always assign "N/A" to 5th attribute of the grain)? Or
this calls for a new fact table with 4 attributes being the grain?

nash

Posts : 18
Join date : 2010-03-12

Back to top Go down

Can a 'fact grain' attribute be null? Empty Re: Can a 'fact grain' attribute be null?

Post  BoxesAndLines Mon Feb 13, 2012 12:58 pm

I don't see any issue. I normally put a surrogate key on my fact tables anyways. The grain is enforced with an alternate key which can have nullable columns.
BoxesAndLines
BoxesAndLines

Posts : 1212
Join date : 2009-02-03
Location : USA

Back to top Go down

Can a 'fact grain' attribute be null? Empty Re: Can a 'fact grain' attribute be null?

Post  nash Mon Feb 13, 2012 5:47 pm


BoxesAndLines wrote: The grain is enforced with an alternate key which can have nullable columns.

Thank for your reply BoxesAndLines and I have the same view too, but I must play a bit of a devil's advocate here

By having 'nullables' in the alternate key, are we mixing grain?
Aren't we saying, in my above example, some facts in the fact table are asserted at the intersection of 5 dimensions while other at 4, and so on?

Pls comment...thanks


nash

Posts : 18
Join date : 2010-03-12

Back to top Go down

Can a 'fact grain' attribute be null? Empty Re: Can a 'fact grain' attribute be null?

Post  BoxesAndLines Mon Feb 13, 2012 6:59 pm

Are the facts at the same grain or a different grain? I.E. If there are multiple facts when you add the final dimension then you have a mixed grain and that is a new table.
BoxesAndLines
BoxesAndLines

Posts : 1212
Join date : 2009-02-03
Location : USA

Back to top Go down

Can a 'fact grain' attribute be null? Empty Re: Can a 'fact grain' attribute be null?

Post  ngalemmo Mon Feb 13, 2012 10:14 pm

nash wrote:
BoxesAndLines wrote: The grain is enforced with an alternate key which can have nullable columns.

Thank for your reply BoxesAndLines and I have the same view too, but I must play a bit of a devil's advocate here

By having 'nullables' in the alternate key, are we mixing grain?
Aren't we saying, in my above example, some facts in the fact table are asserted at the intersection of 5 dimensions while other at 4, and so on?

Pls comment...thanks


The dimensions of a fact table do not necessarily define the level of detail of the facts. It depends on how you define grain. Grain is either conceptual (defined by the dimensions of the fact) or it is defined by the event represented by the facts (true level of detail), which may be a subset of the dimensions associated with the fact. For example, in retail someone may be purchasing something as a gift and, as part of that transaction information is collected on the recipient. As part of the sales fact table, there may be a 'giftee' dimension. While the giftee dimension adds context, it doesn't change the level of detail of the facts. One can reasonably argue that the addition of a giftee dimension does not change the grain of the fact.

If the missing dimension truly affects what the measures represent (in this case, an aggregate of those measures with all dimensions), then you are mixing grains and should use another fact table. However, if the missing dimension does not alter the level of detail of the measures, then having a 'not applicable' dimension row works fine.
ngalemmo
ngalemmo

Posts : 3000
Join date : 2009-05-15
Location : Los Angeles

http://aginity.com

Back to top Go down

Can a 'fact grain' attribute be null? Empty Re: Can a 'fact grain' attribute be null?

Post  nash Sat Feb 18, 2012 3:53 am

ngalemmo wrote:Grain is either conceptual (defined by the dimensions of the fact) or it is defined by the event represented by the facts (true level of detail), which may be a subset of the dimensions associated with the fact. For example, in retail someone may be purchasing something as a gift and, as part of that transaction information is collected on the recipient. As part of the sales fact table, there may be a 'giftee' dimension. While the giftee dimension adds context, it doesn't change the level of detail of the facts. One can reasonably argue that the addition of a giftee dimension does not change the grain of the fact.

I think if I understood your point correctly, you are talking about the minimal grain (the true key). Right? If so then I get that, and it's not an issue at all. As long as true grain is not broken, you could add any number of dimensions.

I will illustrate my problem with an example from retail order process. Say we are interested in monthly order amount and order volume (i.e. #orders) by order type and customer. Our Grain will be Month_Id, Order_Type, Cust_Id with #Orders and $Orders facts that are true to that grain. So far so good.

Let's say if there is another new ordering system that does not provide customer details (may be it's not relevant to their ordering process at all). From this new ordering system we need the same data (without customer info). Now what should we do? Should we:
a. use our existing order fact to store this data. And for customer dimension, we always default to N/A? Or
b. create a new order fact which does not have the customer dimension at all (because it does not make sense for these orders).

What would be your preferrence?

I am highly interested in your views. This example is representative of the real issue I am facing, which is quite large (in terms of number of dimension, number of source systems and data volumes).

Thanks for your time.

nash

Posts : 18
Join date : 2010-03-12

Back to top Go down

Can a 'fact grain' attribute be null? Empty Re: Can a 'fact grain' attribute be null?

Post  ngalemmo Mon Feb 20, 2012 3:20 am

The situation you describe is very common in retail. You would usually reference an 'unknown' customer (option A).
ngalemmo
ngalemmo

Posts : 3000
Join date : 2009-05-15
Location : Los Angeles

http://aginity.com

Back to top Go down

Can a 'fact grain' attribute be null? Empty Re: Can a 'fact grain' attribute be null?

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum