SCD - Type 1 | SCD - Type 3 and 4 |
SCD Type 2
Slowly changing dimension Type 2 is a model where the whole history is stored in the database. An additional dimension record is created and the segmenting between the old record values and the new (current) value is easy to extract and the history is clear.
The fields 'effective date' and 'current indicator' are very often used in that dimension and the fact table usually stores dimension key and version number.
SCD 2 implementation in Datastage
The job described and depicted below shows how to implement SCD Type 2 in Datastage. It is one of many possible designs which can implement this dimension.
For this example, we will use a table with customers data (it's name is D_CUSTOMER_SCD2) which has the following structure and data:
CUST_ID | CUST_ NAME |
CUST_ GROUP_ID |
CUST_ TYPE_ID |
CUST_ COUNTRY_ID |
REC_ VERSION |
REC_ EFFDT |
REC_ CURRENT_IND |
---|---|---|---|---|---|---|---|
DRBOUA7 | Dream Basket | EL | S | PL | 1 | 2006-10-01 | Y |
ETIMAA5 | ETL tools info | BI | C | FI | 1 | 2006-09-29 | Y |
FAMMFA0 | Fajatso | FD | S | CD | 1 | 2006-09-27 | Y |
FICILA0 | First Pactonic | FD | C | IT | 1 | 2006-09-25 | Y |
FRDXXA2 | Frasir | EL | C | SK | 1 | 2006-09-23 | Y |
GAMOPA9 | Ganpa LTD. | FD | C | US | 1 | 2006-09-21 | Y |
GGMOPA9 | GG electronics | EL | S | RU | 1 | 2006-09-19 | Y |
GLMFIA6 | Glasithklini | FD | S | PL | 1 | 2006-09-17 | Y |
GLMPEA9 | Globiteleco | TC | S | FI | 1 | 2006-09-15 | Y |
GONDWA5 | Goli Airlines | BN | S | GB | 1 | 2006-09-13 | Y |
The most important facts and stages of the CUST_SCD2 job processing:
SCD 2 - Customers file extract:
CUST_ID | CUST_ NAME |
CUST_ GROUP_ID |
CUST_ TYPE_ID |
CUST_ COUNTRY_ID |
REC_ VERSION |
REC_ EFFDT |
REC_ CURRENT_IND |
---|---|---|---|---|---|---|---|
DRBOUA7 | Dream Basket | EL | S | PL | 1 | 2006-10-01 | Y |
ETIMAA5 | ETL tools info | BI | C | FI | 1 | 2006-09-29 | N |
FAMMFA0 | Fajatso | FD | S | CD | 1 | 2006-09-27 | Y |
FICILA0 | First Pactonic | FD | C | IT | 1 | 2006-09-25 | Y |
FRDXXA2 | Frasir | EL | C | SK | 1 | 2006-09-23 | Y |
GAMOPA9 | Ganpa LTD. | FD | C | US | 1 | 2006-09-21 | Y |
GGMOPA9 | GG electronics | EL | S | RU | 1 | 2006-09-19 | Y |
GLMFIA6 | Glasithklini | FD | S | PL | 1 | 2006-09-17 | Y |
GLMPEA9 | Globiteleco | TC | S | FI | 1 | 2006-09-15 | Y |
GONDWA5 | Goli Airlines | BN | S | GB | 1 | 2006-09-13 | Y |
ETIMAA5 | ETL-Tools.info | BI | C | ES | 2 | 2006-12-02 | Y |
Back to the Datastage tutorial