April 24, 2014 at 10:29 am
Hi guys,
I have a team of SSIS developers who are experienced OLTP application 4GL programmers but new to SQL, SSIS and data warehousing.
We are having a 'lively' discussion about how to treat Type II SCD changes in dimensions and maintain the integrity of the fact table.
I am using this tutorial as a reference
http://www.zentut.com/data-warehouse/slowly-changing-dimensions/[/url]
For the Type II change where the Olympus XZ1 changes category from Camera to Electronics lets assume that the change was made in April. (for those that don't click on the link the ID changes from 4 to 5 when the product category changes - there is no datefrom, dateto in the example)
Lets say that we are building a Data Warehouse for a rental company to support monthly reporting and we need to be able to support drill downs into previous months reports.
I would have a fact table that looks like this in March.
RecordID - 5467894 (autoincrementing number)
RecordActiveDateID - 12113 (the Date dimension, determining when this record came into force)
RentalAgreementRef - A12456 (the member identifier)
CustomerID - 27 (the customer dimension)
ProductID - 4 (the Product Dimension value from the tutorial)
RentalFeeAmt - £85.22 (the measure)
ContractExpiryDateID - 12478 (the Date dimension)
This means that for March the contract value has accumulated into Camera rentals. For April, the business wants that contract to accumulate into Electronics rentals.
OPTION 1:
I am ascertaining that this Fact table needs to be managed on a Type II basis as well.
This means that for April I need to create a new record
RecordID - 68745714 (autoincrementing number)
RecordActiveDateID - 12321 (the Date dimension, determining when this record came into force)
RentalAgreementRef - A12456 (the member identifier)
CustomerID - 27 (the customer dimension)
ProductID - 5 (the Product Dimension value from the tutorial)
RentalFeeAmt - £85.22 (the measure)
ContractExpiryDateID - 12478 (the Date dimension)
This change to the category for the camera could cause a large insert of records into the fact table, when there have been no changes to the 'facts' just a change to the dimension relationships.
OPTION 2:
Another solution would be to keep the dimension with the same ID number and end date the original dimension value
old / new
ID = 4 / 4
Category = Camera/Electronic
AciveDate = 1stJan / 1stApril
EndDate = 30thMarch / NULL [would really be date dimension ID and 0]
And then you can link to the dimension based on ID and active/end dates but this would be an inefficient match because you would not be able nail the record in the index as you would be searching for dimension records within a date range.
OPTION 3:
My guys are suggesting that we leave the existing fact record and update the ID on the dimension record, then when we need to report, if the dimension record is end dated, use the business key from the 'dead' record to find the equivalent 'live' record in the dimension for reporting but this strikes me as a really bad idea as we will need to cater for the self referencing join in every query.
- They say this is the way they were told to do it on a training course - I rate the guy that ran the course, but I think they have mis-understood the scenario that was described.
QUESTION:
Who is right or is there another option
April 24, 2014 at 2:18 pm
Very important thing to know: the RentalFeeAmount, how is this calculated? How is this used?
If it is a normal measure - additive and all that - option 1 is flat out wrong as you would double count amounts.
But I guess more is going on here.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
April 25, 2014 at 3:14 am
RentalFeeAmount is a fully additive measure.
The fact table would be consumed within a view to provide the most recent record version at the reporting date and it is the view that gets rolled up on the dimensional values.
So the when the view is run with a March date, the first copy of the record is provided, and any view date for April onwards would give the second copy of the record. In this respect the change to the dimensional surrogate key would be treated no differently from a change in a real fact (e.g. the customer had traded in the original 'camera' item for a completely different 'electronics' item but still on the same terms and agreement number.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply