Q) How to create or implement slowly changing dimension (SCD) Type 2 Effective Date mapping in informatica?

SCD type 2 will store the entire history in the dimension table. In SCD type 2 effective date, the dimension table will have Start_Date (Begin_Date) and End_Date as the fields. If the End_Date is Null, then it indicates the current row. Know more about SCDs at Slowly Changing Dimensions Concepts. We will see how to implement the SCD Type 2 Effective Date in informatica. As an example consider the customer dimension. The source and target table structures are shown below:
--Source Table

Create Table Customers ( Customer_Id Number Primary Key, Location ); Varchar2(30)

--Target Dimension Table

Create Table Customers_Dim ( Cust_Key Number Primary Key, Customer_Id Location Begin_Date End_Date ); Number, Varchar2(30), Date, Date

Go to the toolbar. Go to the mapping designer tab and create new mapping. Open the mapping designer tool. Edit the lookup transformation.Part 1 Here we will see the basic set up and mapping flow require for SCD type 2 Effective Date. Identify the changed record and update the existing record in dimension table with End_Date as Curren date. Identifying the changed record and inserting into the dimension table with Begin_Date as the Current date (SYSDATE) and End_Date as NULL. This new port needs to be connected to the customer_id port of the source qualifier transformation. Go to the Warehouse designer or Target designer and import the target definition. We will divide the steps to implement the SCD type 2 Effective Date mapping into four parts. The steps involved are:        Create the source and dimension tables in the database.The basic steps involved in creating a SCD Type 2 Effective Date mapping are    Identifying the new records and inserting into the dimension table with Begin_Date as the Current date (SYSDATE) and End_Date as NULL. go to the ports tab and remove unnecessary ports. You will get a window as shown in the below image. source analyzer and either create or import the source definition. Drag the source into the mapping.   Select the customer dimension table and click on OK. Just keep only Cust_key. Transformation and then Create. SCD Type 2 Effective Date implementation . customer_id and location ports in the lookup transformation. enter a name and click on create. . Select the lookup Transformation. Create a new port (IN_Customer_Id) in the lookup transformation.

1. Connect the customer_id port of source qualifier transformation to the In_Customer_Id port of the LKP transformation. Create an expression transformation with input/output ports as Cust_Key. SELECT Customers_Dim. Src_Location and output ports as New_Flag. LKP_Location.End_Date IS NULL   Click on Ok in the lookup transformation.0) Changed_Flag = IIF( NOT ISNULL(Cust_Key) AND .Customer_Id as Customer_Id FROM WHERE Customers_Dim Customers_Dim.Cust_Key as Cust_Key. New_Flag = IIF(ISNULL(Cust_Key). Customers_Dim.  Go to the conditions tab of the lookup transformation and enter the condition as Customer_Id = IN_Customer_Id Go to the properties tab of the LKP transformation and enter the below query in Lookup SQL Override. Alternatively you can generate the SQL query by connecting the database in the Lookup SQL Override expression editor and then add the WHERE clause. Enter the below expressions for output ports. Changed_Flag.Location as Location. Customers_Dim.

we will identify the new records and insert them into the target with Begin Date as the current date. SCD Type 2 Effective Date implementation . Drag the ports of expression transformation (New_Flag) and source qualifier transformation (Customer_Id. Location) into the filter transformation.LKP_Location != SRC_Location.Part 2 In this part. Go to the properties tab and enter the update strategy expression as DD_INSERT. Create a sequence generator and an expression transformation. Begin_Date). Now connect the ports of expression transformation (Nextval. The part of the mapping flow is shown in the below image. Now drag the target definition into the mapping and connect the appropriate ports of update strategy transformation to the target definition. . Location). Call this expression transformation as "Expr_Date". 1. Go the properties tab of filter transformation and enter the filter condition as New_Flag=1 Now create a update strategy transformation and connect the ports of filter transformation (Customer_Id. Begin_Date) to the Target definition ports (Cust_Key. 0)  The part of the mapping flow is shown below. Drag and connect the NextVal port of sequence generator to the Expression transformation. The steps involved are:        Now create a filter transformation to identify and insert new record in to the dimension table. In the expression transformation create a new output port (Begin_Date with date/time data type) and assign value SYSDATE to it.

This is used to find the changed records. The part of the mapping diagram is shown below. Now create an update strategy transformation and drag the ports of Filter transformation (customer_id. Begin_Date ports of the target definition respectively. we will identify the changed records and insert them into the target with Begin Date as the current date. Now drag the target definition into the mapping and connect the appropriate ports of update strategy transformation to the target definition. . location) into the update strategy transformation. Begin_Date ports of expression transformation (Expr_Date created in part 2) to the cust_key. LKP transformation (Cust_Key) into the filter transformation. location).SCD Type 2 Effective Date implementation . source qualifier transformation (customer_id. Now drag the ports from expression transformation (changed_flag).Part 3 In this part. Call this filter transformation as FIL_Changed. Go to the filter transformation properties and enter the filter condition as changed_flag =1. Now connect the Next_Val. Go to the properties tab and enter the update strategy expression as DD_INSERT. The steps involved are:      Create a filter transformation.

The complete mapping image is shown . Go to the ports tab of expression transformation and create a new output port (End_Date with date/time data type). Assign a value SYSDATE to this port.     Create an expression transformation and drag the Cust_Key port of filter transformation (FIL_Changed created in part 3) into the expression transformation. Now create an update strategy transformation and drag the ports of the expression transformation into it. Go to the properties tab and enter the update strategy expression as DD_UPDATE.Part 4 In this part.SCD Type 2 Effective Date implementation . we will update the changed records in the dimension table with End Date as current date. Drag the target definition into the mapping and connect the appropriate ports of update strategy to it.

Know more about SCDs at Slowly Changing Dimensions Concepts.below. Varchar2(30) --Target Dimension Table . We will see how to implement the SCD Type 2 Flag in informatica. Location ). The source and target table structures are shown below: --Source Table Create Table Customers ( Customer_Id Number Primary Key. Q) How to create or implement slowly changing dimension (SCD) Type 2 Flagging mapping in informatica? SCD type 2 will store the entire history in the dimension table. As an example consider the customer dimension.

Transformation and then Create. Select the lookup Transformation. Identifying the changed record and inserting into the dimension table with flag value as one. Number. The steps involved are:        Create the source and dimension tables in the database. . You will get a window as shown in the below image. enter a name and click on create. Number The basic steps involved in creating a SCD Type 2 Flagging mapping are    Identifying the new records and inserting into the dimension table with flag column value as one. Go to the Warehouse designer or Target designer and import the target definition.Part 1 Here we will see the basic set up and mapping flow require for SCD type 2 Flagging. Customer_Id Location Flag ). source analyzer and either create or import the source definition. Go to the mapping designer tab and create new mapping. Varchar2(30). SCD Type 2 Flag implementation . Identify the changed record and update the existing record in dimension table with flag value as zero. Go to the toolbar. Drag the source into the mapping. We will divide the steps to implement the SCD type 2 flagging mapping into four parts.Create Table Customers_Dim ( Cust_Key Number Primary Key. Open the mapping designer tool.

Customer_Id as Customer_Id .   Go to the conditions tab of the lookup transformation and enter the condition as Customer_Id = IN_Customer_Id Go to the properties tab of the LKP transformation and enter the below query in Lookup SQL Override. Just keep only Cust_key.  Select the customer dimension table and click on OK. customer_id and location ports in the lookup transformation.Cust_Key as Cust_Key. Create a new port (IN_Customer_Id) in the lookup transformation. This new port needs to be connected to the customer_id port of the source qualifier transformation. Edit the lookup transformation. go to the ports tab and remove unnecessary ports. Customers_Dim. Customers_Dim. Alternatively you can generate the SQL query by connecting the database in the Lookup SQL Override expression editor and then add the WHERE clause.Location as Location. SELECT Customers_Dim.

0)  The part of the mapping flow is shown below. Enter the below expressions for output ports. The steps involved are: . Create an expression transformation with input/output ports as Cust_Key.FROM WHERE Customers_Dim Customers_Dim. Changed_Flag.0) Changed_Flag = IIF( NOT ISNULL(Cust_Key) AND LKP_Location != SRC_Location.Part 2 In this part. SCD Type 2 Flag implementation . 1. Src_Location and output ports as New_Flag. Connect the customer_id port of source qualifier transformation to the In_Customer_Id port of the LKP transformation. we will identify the new records and insert them into the target with flag value as 1. LKP_Location. New_Flag = IIF(ISNULL(Cust_Key).Flag = 1   Click on Ok in the lookup transformation. 1.

Go the properties tab of filter transformation and enter the filter condition as New_Flag=1 Now create a update strategy transformation and connect the ports of filter transformation (Customer_Id. Drag and connect the NextVal port of sequence generator to the Expression transformation.       Now create a filter transformation to identify and insert new record in to the dimension table. Location) into the filter transformation. This is used to find the changed records. LKP transformation (Cust_Key) into the filter transformation. we will identify the changed records and insert them into the target with flag value as 1. Now connect the ports of expression transformation (Nextval. source qualifier transformation (customer_id. SCD Type 2 Flag implementation . The steps involved are:     Create a filter transformation. Now drag the ports from expression transformation (changed_flag). Call this filter transformation as FIL_Changed. Create a sequence generator and an expression transformation. Go to the properties tab and enter the update strategy expression as DD_INSERT. Flag) to the Target definition ports (Cust_Key. Now create an update strategy transformation and drag the ports of Filter transformation (customer_id. The part of the mapping flow is shown in the below image. Location). . Go to the filter transformation properties and enter the filter condition as changed_flag =1.Part 3 In this part. location) into the update strategy transformation. Now drag the target definition into the mapping and connect the appropriate ports of update strategy transformation to the target definition. In the expression transformation create a new output port (Flag) and assign value 1 to it. Drag the ports of expression transformation (New_Flag) and source qualifier transformation (Customer_Id. Go to the properties tab and enter the update strategy expression as DD_INSERT. location). Flag). Call this expression transformation as "Expr_Flag". Now drag the target definition into the mapping and connect the appropriate ports of update strategy transformation to the target definition.

Flag ports of expression transformation (Expr_Flag created in part 2) to the cust_key. Now create an update strategy transformation and drag the ports of the expression transformation into it. Drag the target definition into the mapping and connect the appropriate ports of update strategy to it. Assign a value "0" to this Flag port. SCD Type 2 Flag implementation .     Create an expression transformation and drag the Cust_Key port of filter transformation (FIL_Changed created in part 3) into the expression transformation. The part of the mapping diagram is shown below. Go to the properties tab and enter the update strategy expression as DD_UPDATE. Flag ports of the target definition respectively. The complete mapping image is show .Part 4 In this part. Go to the ports tab of expression transformation and create a new output port (Flag). Now connect the Next_Val. we will update the changed records in the dimension table with flag value as 0.

Scd implementation .n below.