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


Type II changes in Dimension tables and the associated surrogate key in Fact table


Type II changes in Dimension tables and the associated surrogate key in Fact table

Author
Message
aaron.reese
aaron.reese
Mr or Mrs. 500
Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)

Group: General Forum Members
Points: 589 Visits: 898
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/

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
Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16471 Visits: 13207
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.



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
aaron.reese
aaron.reese
Mr or Mrs. 500
Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)

Group: General Forum Members
Points: 589 Visits: 898
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.
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