SCD 2 implementation
3 posters
Page 1 of 1
SCD 2 implementation
I have an ORDER fact table and CUSTOMER dimension.
I filled the CUSTOMER dimension with the source tables like : tcustomers, tlanguages.
TLANGUAGES:
LANGUAGE_ID | LANGUAGE_NAME
1 | English
2 | Italian
3 | Arabic
TCUSTOMERS
CUSTOMER_ID | CUSTOMER_NAME | LANGUAGE_ID
1 | John | 1
2 | Jamie | 3
3 | Susan | 1
When I create the dimension I use the following sql:
SELECT
t1.customer_name,
t2.language_name
FROM
tlanguages t1, tcustomer t2 WHERE t1.language_id = t2.language_id
So far, It works. Okey.
When the language has changed I want to insert a new record. But I do not want to insert a new record when the language_name column has been modified.
For example if the customer language id changed from 1 to 2 I should add new record. But if customer language change from 'English' to 'Eng' I do not want to insert new record.
Assume that in the tlanguages table 'English' has changed to 'ENG'. If I use the above join statement and compare the data set I see that language_name has been changed and I will add new record. But I should not do that. Becasue English and ENG are the same.
What is the best practice of this problem ? Should I control the language_id ? What will you do if you were me?
I filled the CUSTOMER dimension with the source tables like : tcustomers, tlanguages.
TLANGUAGES:
LANGUAGE_ID | LANGUAGE_NAME
1 | English
2 | Italian
3 | Arabic
TCUSTOMERS
CUSTOMER_ID | CUSTOMER_NAME | LANGUAGE_ID
1 | John | 1
2 | Jamie | 3
3 | Susan | 1
When I create the dimension I use the following sql:
SELECT
t1.customer_name,
t2.language_name
FROM
tlanguages t1, tcustomer t2 WHERE t1.language_id = t2.language_id
So far, It works. Okey.
When the language has changed I want to insert a new record. But I do not want to insert a new record when the language_name column has been modified.
For example if the customer language id changed from 1 to 2 I should add new record. But if customer language change from 'English' to 'Eng' I do not want to insert new record.
Assume that in the tlanguages table 'English' has changed to 'ENG'. If I use the above join statement and compare the data set I see that language_name has been changed and I will add new record. But I should not do that. Becasue English and ENG are the same.
What is the best practice of this problem ? Should I control the language_id ? What will you do if you were me?
ozisamur- Posts : 30
Join date : 2014-10-27
Re: SCD 2 implementation
It is not unusual to have a type 2 dimension with some type 1 (non-historical) attributes. Such attributes are updated in place across all applicable rows.
Re: SCD 2 implementation
Actually My question is something related about the column which is both scd 1 and scd 2.
If the language is changed from English to Italian I should add new row but from English to ENG I should not add new row. Just change it. But I filled the language text column via a join and English is different for ENG and Italian. How should I implement the SCD 2 ?
If the language is changed from English to Italian I should add new row but from English to ENG I should not add new row. Just change it. But I filled the language text column via a join and English is different for ENG and Italian. How should I implement the SCD 2 ?
ozisamur- Posts : 30
Join date : 2014-10-27
Re: SCD 2 implementation
Store the ID in the customer dimension as well as the description. Treat the language description as a type 1 attribute in a type 2 table. The user doesn't need to see the ID, but it is needed to help maintain the dimension.
Re: SCD 2 implementation
Thanks, I think that is the easisest solution I have ever heard !
ozisamur- Posts : 30
Join date : 2014-10-27
Re: SCD 2 implementation
You mentioned that you have a ORDER Fact table. That tells me your customer buying things. If your customer are buying books (English or Italian), then language is not an attribute of a customer dim. You need a separate Language dim. Use your Fact table to bring Customer and Language dim keys together which is based on the Order transaction.
zoom- Posts : 97
Join date : 2010-08-23
Location : Chicago
Re: SCD 2 implementation
While it is certainly conceivable language could be an attribute of a product, a language dimension is a bit overkill. In the original poster's case, it is an attribute of customer, which is very common in retail models to support customer engagement (marketing, customer service, etc…). Relegating it as a dimension off a fact simply does not work in such an environment.
Similar topics
» Modified SCD 2 implementation
» Type 2 SCD Fact Implementation
» Agile / Rapid BI Implementation
» Implementation Bridge Table
» Junk Dimension Implementation
» Type 2 SCD Fact Implementation
» Agile / Rapid BI Implementation
» Implementation Bridge Table
» Junk Dimension Implementation
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum