Slowly Changing Dimension (SCD2)
- Although dimension tables are typically static lists, most dimension tables do change over time.
- Since these changes are smaller in magnitude compared to changes in fact tables, these dimensions are known as slowly growing or slowly changing dimensions.
- If we load first Time
- Second Time load
- Third time load
STEP 1 : Creating and Reverse Engineering Source
- We can use EMP table of SCOTT schema as source
- Reverse engineer EMP table into SOURCE MODEL
STEP 2 : Creating and Reverse Engineering Target
- Create target table in Target Schema using below script
CREATE TABLE TGT_SCD2_EMP
( SURR_EMPNO NUMBER PRIMARY KEY,
EMPNO NUMBER(4,0),
ENAME VARCHAR2(10 BYTE),
JOB VARCHAR2(9 BYTE),
SAL NUMBER(7,2),
DEPTNO NUMBER(2,0),
CURR_FLG NUMBER,
EFF_FROM_DT DATE,
EFF_TO_DT DATE
)
|
- Reverse engineer into TARGET MODEL
STEP 3 : Configuration for SCD
- Right Click on table TGT_SCD2_EMP2 → Click on OPEN → Select OLAP Type as Slowly Changing Dimension → Save → Close
- Expand table → Expand columns → right click on one by one column and set as shown below
- Save and close one by one
STEP 4 : Creating Interface/Mapping
- Create interface with the name of m_SCD2
- Click on mapping tab → Drag and drop source (EMP)and target (TGT_SCD2_EMP2)in respective locations
- Map columns as shown
S NO
|
Target Column Name
|
Expression
|
Comments
|
1
|
SURR_EMPNO
|
Map to existing sequence
:NAT_SEQ_SCD_NEXTVAL
|
Create new sequence or map to existing sequence
|
2
|
EMPNO
|
EMP.EMPNO
| |
3
|
ENAME
|
EMP.ENAME
| |
4
|
JOB
|
EMP.JOB
| |
5
|
SAL
|
EMP.SAL
| |
6
|
DEPTNO
|
EMP.DEPTNO
| |
7
|
CURR_FLG
|
0
| |
8
|
EFF_FROM_DT
|
SYSDATE
| |
9
|
EFF_TO_DT
|
SYSDATE
|
- Click on Flow tab
- Select Target and select IKM Oracle Slowly Changing Dimension
- Select FLOW_CONTROL = False
- Click on SAVE
- Click on RUN
- Change source data sal and run again
- Again change source data sal run (in my case i changed Ram Reddy sal from 10000 to 30000 and 30000 to 35000)
No comments:
Post a Comment