Friday, 6 June 2014

Slowly Changing Dimensions

Slowly Changing Dimensions (SCD) - dimensions that change slowly over time, rather than changing on regular schedule, time-base. In Data Warehouse there is a need to track changes in dimension attributes in order to report historical data.

There are many approaches how to deal with SCD. The most popular are:

Type 0 - The passive method
Type 1 - Overwriting the old value
Type 2 - Creating a new additional record
Type 3 - Adding a new column
Type 4 - Using historical table
Type 6 - Combine approaches of types 1,2,3 (1+2+3=6)

Type 0 - The passive method. In this method no special action is performed upon dimensional changes. Some dimension data can remain the same as it was first time inserted, others may be overwritten.

Type 1 - Overwriting the old value. In this method no history of dimension changes is kept in the database. The old dimension value is simply overwritten be the new one. This type is easy to maintain and is often use for data which changes are caused by processing corrections(e.g. removal special characters, correcting spelling errors).

Before the change: 
Customer_IDCustomer_NameCustomer_Type
1Cust_1Corporate


After the change: 
Customer_IDCustomer_NameCustomer_Type
1Cust_1Retail

Type 2 - Creating a new additional record. In this methodology all history of dimension changes is kept in the database. You capture attribute change by adding a new row with a new surrogate key to the dimension table. Both the prior and new rows contain as attributes the natural key(or other durable identifier). Also 'effective date' and 'current indicator' columns are used in this method. There could be only one record with current indicator set to 'Y'. For 'effective date' columns, i.e. start_date and end_date, the end_date for current record usually is set to value 9999-12-31. Introducing changes to the dimensional model in type 2 could be very expensive database operation so it is not recommended to use it in dimensions where a new attribute could be added in the future.

Before the change: 
Customer_IDCustomer_NameCustomer_TypeStart_DateEnd_DateCurrent_Flag
1Cust_1Corporate22-07-201031-12-9999Y


After the change: 
Customer_IDCustomer_NameCustomer_TypeStart_DateEnd_DateCurrent_Flag
1Cust_1Corporate22-07-201017-05-2012N
2Cust_1Retail18-05-201231-12-9999Y

Type 3 - Adding a new column. In this type usually only the current and previous value of dimension is kept in the database. The new value is loaded into 'current/new' column and the old one into 'old/previous' column. Generally speaking the history is limited to the number of column created for storing historical data. This is the least commonly needed techinque. 

Before the change: 
Customer_IDCustomer_NameCurrent_TypePrevious_Type
1Cust_1CorporateCorporate


After the change: 
Customer_IDCustomer_NameCurrent_TypePrevious_Type
1Cust_1RetailCorporate
Type 4 - Using historical table. In this method a separate historical table is used to track all dimension's attribute historical changes for each of the dimension. The 'main' dimension table keeps only the current data e.g. customer and customer_history tables. 

Current table:
Customer_IDCustomer_NameCustomer_Type
1Cust_1Corporate


Historical table: 
Customer_IDCustomer_NameCustomer_TypeStart_DateEnd_Date
1Cust_1Retail01-01-201021-07-2010
1Cust_1Oher22-07-201017-05-2012
1Cust_1Corporate18-05-201231-12-9999
Type 6 - Combine approaches of types 1,2,3 (1+2+3=6). In this type we have in dimension table such additional columns as:
current_type - for keeping current value of the attribute. All history records for given item of attribute have the same current value.
historical_type - for keeping historical value of the attribute. All history records for given item of attribute could have different values.
start_date - for keeping start date of 'effective date' of attribute's history.
end_date - for keeping end date of 'effective date' of attribute's history.
current_flag - for keeping information about the most recent record.

In this method to capture attribute change we add a new record as in type 2. The current_type information is overwritten with the new one as in type 1. We store the history in a historical_column as in type 3. 

Customer_IDCustomer_NameCurrent_TypeHistorical_TypeStart_DateEnd_DateCurrent_Flag
1Cust_1CorporateRetail01-01-201021-07-2010N
2Cust_1CorporateOther22-07-201017-05-2012N
3Cust_1CorporateCorporate18-05-201231-12-9999Y

Thursday, 5 June 2014

Expression Transformation

Expression transformation is a passive and connected transformation. This can be used to calculate values in a single row before writing to the target. For example, to calculate discount of each product or to concatenate first and last names or to convert date to a string field.

Difference between Joiner and Union Transformation

Joiner:


  • Using joiner we can remove duplicate rows
  • Joiner can be Normal,Right Outer,Left Outer,Full Outer Join
  • In Joiner we have one input group and one output group
  • Joiner implemented by using Joiner Transformation in Informatica.
  • Joiner Transformation combines data record horizontally based on a join condition


Union:


  • Union will not remove duplicate rows
  • Union is equlivalent to UNION ALL in SQL
  • In Union we have multiple input groups and one output group.
  • Union implemented by using Union Transformation in Informatica
  • Union Transformation combines data record vertically from multiple sources
  • Union also supports hetregenous(different sources)

Union Transformation


  • Union transformation is connected and active transformation.
  • Union transformation is used to merge data from multiple pipelines into single one.
  • Merges similar data coming from heterogeneous and homogeneous sources.
  • Multiple input groups but only one output group (Opposite to Router)

Lookup Transformation

A Lookup is a Passive, Connected or Unconnected Transformation used to look up data in a relational table, view, synonym or flat file. The integration service queries the lookup table to retrieve a value based on the input source value and the lookup condition.

A connected lookup recieves source data, performs a lookup and returns data to the pipeline;
 
While an unconnected lookup is not connected to source or target and is called by a transformation in the pipeline by :LKP expression which in turn returns only one column value to the calling transformation.

Lookup can be Cached or Uncached. If we cache the lookup then again we can further go for static or dynamic or persistent cache,named cache or unnamed cache .

Source Qualifier Transformation

Source Qualifier transformation is an active and connected transformation. When adding a relational or a flat file source definition to a mapping, it is must to connect it to a Source Qualifier Transformation. The Source Qualifier performs the various tasks such as overriding default SQL query, filtering records; join data from two or more tables etc.

Joiner Transformation

Joiner transformation is an active and connected transformation. This can be used to join two sources coming from two different locations or from same locations. For example, to join a flat file and a relational source or to join two flat files  or to join a relational source and XML source.

In order to join two sources, there must be at least one matching port. While joining two sources it is a must to specify one source as master and the other as detail.

The joiner transformation supports the following types of joins:


  • Normal 
  • Master outer
  • Detail outer 
  • Full outer


Normal join discards all the rows of data from the master and detail source that do not match, based on the condition.

Master outer join discards all the unmatched rows from the master source and keeps all the rows from the detail source and the matching rows from the master source.

Detail outer join keeps all the rows of data from the master source and the matching rows from the detail source. It discards the unmatched rows from the detail source.

Full outer join keeps all rows of data from both the master and detail sources.

Kiro - Core Features

What is Kiro Kiro is an innovative AI-powered IDE that revolutionizes software development through intelligent assistance and structured wor...