Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Populating Fact Tables


Populating Fact Tables

Author
Message
dudley
dudley
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 145
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
VincentRainardi
VincentRainardi
SSC Journeyman
SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)

Group: General Forum Members
Points: 83 Visits: 191
Yes you are right Dudley, we can create the product dimension row based on the product ID to handle late arriving dimension data.
MTY-1082557
MTY-1082557
SSC Veteran
SSC Veteran (256 reputation)SSC Veteran (256 reputation)SSC Veteran (256 reputation)SSC Veteran (256 reputation)SSC Veteran (256 reputation)SSC Veteran (256 reputation)SSC Veteran (256 reputation)SSC Veteran (256 reputation)

Group: General Forum Members
Points: 256 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
VincentRainardi
VincentRainardi
SSC Journeyman
SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)

Group: General Forum Members
Points: 83 Visits: 191
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search