Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Populating Fact Tables Expand / Collapse
Author
Message
Posted Monday, April 28, 2008 12:09 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 11:02 PM
Points: 4, Visits: 130
Hi Vincent

Nice overall concise article, however I don't agree with your Unknown record solution. The product dimension is not unknown, but rather only the atributes are unknown. But creating a force record of the product_id you don't lose the product_id information. Business can decide what they want as defaults for the product attributes So your data will now look like this:

Here is an example of a row in the source table with a product_id that does not exist in the dimension table:
order_id order_date product_id quantity price last_update
358 19/08/2006 BGCKZ 3 2.99 31/10/2006

"Force" the unknown product_id as an actual dimension record.
product_key product_id product_name description min_level valid_until load_time
231 BGCKZ Unknown Late Arriving 0 1/1/1900 2/10/2004

Now your lookups will still be accurate.
This is how fact_sales looks after that record is loaded:
fact_key date_key product_key order_id quantity price load_time
830937 2424 231 358 3 2.99 31/10/2006

This solves a problem for late arriving dimension records. Due to bad/unusual business process you may receive the product details for BGCKZ a few days after the fact record. It is just a matter of updating the existing dimension record with the correct details. This way business as well a foreign key integrity is preserved.

Regards,
Dudley
Post #491195
Posted Thursday, December 11, 2008 6:26 AM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, January 14, 2013 4:24 AM
Points: 81, Visits: 188
Yes you are right Dudley, we can create the product dimension row based on the product ID to handle late arriving dimension data.
Post #617834
Posted Tuesday, May 4, 2010 11:58 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 30, 2010 7:19 AM
Points: 246, Visits: 502
Hi Vincent,

Your article is great for me, it’s the first time I’m working with data marts. I just created my first environment (still in the development/test mode). I read your book as well. I will work on SSIS, for now I’m creating my processes on SQL to understand the behavior of the records.

My Fact table has some aggregation columns (more than Key columns). This fact table will be used for reporting. All the reports will use the information from this Fact Table and they will be run with a parameter of date range and client id. (date_Key and Client_Key)

How exactly I will call my report and my aggregates. I mean, this is a Data Mart “natural” behavior? Some aggregate columns are percentages or probability calculations. I assume I will aggregate the aggregates in order to have a report for one month.

Do you have an example of how to get the information (Report) from the fact table with SQL?

Thank you

Post #915551
Posted Wednesday, May 5, 2010 2:31 PM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, January 14, 2013 4:24 AM
Points: 81, Visits: 188
Hi MTY,
"aggregate column which is more than key columns"
I think what you mean is a measure column which is duplicated across rows. The Kimball term for this situation is: the measure doesn't match the grain of the fact table. Generally, this means that that measure does not belong to this fact table and you would have to build another fact table for that measure, with the right grain.

"how exactly I will call my report and my aggregates"
A typical star join query used to retrieve measures from the fact table is
select d1.attribute1, d2.attribute1, sum(f.measure1)
from fact1 f
inner join dimension1 d1 on d1.d1_key = f1.d1_key
inner join dimension2 d2 on d2.d2_key = f1.d2_key
group by d1.attribute1, d2.attribute1

If your measure doesn't satisfy the grain of the fact table you will encounter double counting. Hence the recommendation is that you have to move that measure column to other fact table so that it can be summed up correctly.
If however, you insist of putting that measure in this fact table, then you would have to take a max, min or average (or other aggregate SQL function like rank).

"some aggregate columns are percentages or probability calculations"
With percentage measures generally we will have to persist (store) it as 2 columns in the fact table: the nominator (A) and the denominator (B). The report or cube will then do the calculation A/B to get the percentage. Same with probability.

Hope this helps,
Vincent
Post #916479
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse