SCD Type-1: A Type 1 change overwrites an existing dimensional attribute with new information. In the customer name-change example, the new name overwrites the old name, and the value for the old version is lost. A Type One change updates only the attribute, doesn't insert new records, and affects no keys. It is easy to implement but does not maintain any history of prior attribute values
Implementation:Source:
Create CUST source using following script.
CREATE TABLE CUST
(CUST_ID NUMBER,
CUST_NM VARCHAR2(250 BYTE),
ADDRESS VARCHAR2(250 BYTE),
CITY VARCHAR2(50 BYTE),
STATE VARCHAR2(50 BYTE),
INSERT_DT DATE,
UPDATE_DT DATE);
CREATE TABLE CUST
(CUST_ID NUMBER,
CUST_NM VARCHAR2(250 BYTE),
ADDRESS VARCHAR2(250 BYTE),
CITY VARCHAR2(50 BYTE),
STATE VARCHAR2(50 BYTE),
INSERT_DT DATE,
UPDATE_DT DATE);
Target:
CREATE TABLE STANDALONE.CUST_D(PM_PRIMARYKEY INTEGER,CUST_ID NUMBER,CUST_NM VARCHAR2(250 BYTE),ADDRESS VARCHAR2(250 BYTE),CITY VARCHAR2(50 BYTE),STATE VARCHAR2(50 BYTE),INSERT_DT DATE,UPDATE_DT DATE);CREATE UNIQUE INDEX STANDALONE.CUST_D_PK ON STANDALONE.CUST_D(PM_PRIMARYKEY);ALTER TABLE CUST_D ADD (CONSTRAINT CUST_D_PK PRIMARY KEY(PM_PRIMARYKEY));
- Import Source and target in to informatica using source analyzer and target designer.
- Create mapping m_Use_Dynamic_Cache_To_SCD_Type1 and drag CUST source from sources to mapping designer.
Create lookup transformation lkp_CUST_D for CUST_D target table.
Create input ports in_CUST_ID, in_CUST_NM, in_ADDRESS, in_CITY and in_STATE attributes in lkp_CUST_D transformation. Connect CUST_ID, CUST_NM, ADDRESS, CITY and STATE from source qualifier to lookup lkp_CUST_D table in_CUST_ID, in_CUST_NM, in_ADDRESS, in_CITY and in_STATE attributes respectively.
Create condition in lookup transformation CUST_ID=in_CUST_ID in conditions tab.
Create condition in lookup transformation CUST_ID=in_CUST_ID in conditions tab.
Select dynamic cache and insert else update options in lookup transformation properties.
Assign ports for lookup ports as shown in below screen shot.
Create expression transformation and drag all attributes from lookup transformation and drop in expression transformation and change the name of attributes in expression transformation with respect to source attributes or target attributes, so that it is easy to understand the fields which are coming from source and target.
Create one dummy out port in expression transformation to pass date to target and assign SYSDATE in expression editor.
Create router transformation and drag attributes from expression transformation to router transformation as shown in below screen shot.
Create two groups in router transformation one for INSERT and another one for UPDATE.
Give condition NewLookupRow=1 for insert group and NewLookupRow=2 for update group.
Give condition NewLookupRow=1 for insert group and NewLookupRow=2 for update group.
Connect insert group from router to insert pipe line in target and update group to update pipe line target through update strategy transformation.
For update strategy transformation upd_INSERT give condition DD_INSERT and DD_UPDATE for upd_UPDATE update strategy transformation
Create work flow wkfl_Use_Dynamic_Cache_To_SCD_Type1 with session s_Use_Dynamic_Cache_To_SCD_Type1 for mapping m_Use_Dynamic_Cache_To_SCD_Type1.
Create work flow wkfl_Use_Dynamic_Cache_To_SCD_Type1 with session s_Use_Dynamic_Cache_To_SCD_Type1 for mapping m_Use_Dynamic_Cache_To_SCD_Type1.
With coding for SCD Type1 by using Dynamic lookup transformation completed.
Execution:
Execution:
Insert records in source CUST table by using following insert scripts.
Insert into CUST (CUST_ID, CUST_NM, ADDRESS, CITY, STATE, INSERT_DT, UPDATE_DT)
Values (80001, 'Marion Atkins', '100 Main St.', 'Bangalore', 'KA', SYSDATE,SYSDATE);
Insert into CUST (CUST_ID, CUST_NM, ADDRESS, CITY, STATE, INSERT_DT, UPDATE_DT)
Values (80001, 'Marion Atkins', '100 Main St.', 'Bangalore', 'KA', SYSDATE,SYSDATE);
Insert into CUST (CUST_ID, CUST_NM, ADDRESS, CITY, STATE, INSERT_DT, UPDATE_DT)
Values (80002, 'Laura Jones', '510 Broadway Ave.', 'Hyderabad', 'AP', SYSDATE,SYSDATE);
Insert into CUST (CUST_ID, CUST_NM, ADDRESS, CITY, STATE, INSERT_DT, UPDATE_DT)
Values (80003, 'Jon Freeman', '555 6th Ave.', 'Bangalore', 'KA', SYSDATE,SYSDATE);
COMMIT;
Data in source will look like below.
Start work flow after insert the records in CUST table. After completion of this work flow all the records will be loaded in target and data will be look like below.
Now update any record in source and re run the work flow it will update record in target. If any records in source which are not present in target will be inserted in target table.
wow, awesome post.Really looking forward to read more. Will read on…
ReplyDeletesccm online course
spark online course