Monday, September 30, 2013

Constraint Based Loading

Constraint-Based Loading is used to load the corresponding transformed row first to the primary key table, then to any foreign key tables.

In the Workflow Manager, you can specify constraint-based loading for a session. When you select this option, the Integration Service orders the target load on a row-by-row basis. For every row generated by an active source, the Integration Service loads the corresponding transformed row first to the primary key table, then to any foreign key tables. Constraint-based loading depends on the following requirements:
  • Active source.Related target tables must have the same active source.
  • Key relationships. Target tables must have key relationships.
  • Target connection groups. Targets must be in one target connection group.
  • Treat rows as insert. Use this option when you insert into the target. You cannot use updates with constraint-based loading.

Active Source
When target tables receive rows from different active sources, the Integration Service reverts to normal loading for those tables, but loads all other targets in the session using constraint-based loading when possible. For example, a mapping contains three distinct pipelines. The first two contain a source, source qualifier, and target. Since these two targets receive data from different active sources, the Integration Service reverts to normal loading for both targets. The third pipeline contains a source, Normalizer, and two targets. Since these two targets share a single active source (the Normalizer), the Integration Service performs constraint-based loading: loading the primary key table first, then the foreign key table.

Key Relationships
When target tables have no key relationships, the Integration Service does not perform constraint-based loading. Similarly, when target tables have circular key relationships, the Integration Service reverts to a normal load. For example, you have one target containing a primary key and a foreign key related to the primary key in a second target. The second target also contains a foreign key that references the primary key in the first target. The Integration Service cannot enforce constraint-based loading for these tables. It reverts to a normal load.

Target Connection Groups
The Integration Service enforces constraint-based loading for targets in the same target connection group. If you want to specify constraint-based loading for multiple targets that receive data from the same active source, you must verify the tables are in the same target connection group. If the tables with the primary key-foreign key relationship are in different target connection groups, the Integration Service cannot enforce constraint-based loading when you run the workflow.

To verify that all targets are in the same target connection group, complete the following tasks:
  • Verify all targets are in the same target load order group and receive data from the same active source.
  • Use the default partition properties and do not add partitions or partition points.
  • Define the same target type for all targets in the session properties.
  • Define the same database connection name for all targets in the session properties.
  • Choose normal mode for the target load type for all targets in the session properties.

Treat Rows as Insert
Use constraint-based loading when the session option Treat Source Rows As is set to Insert. You might get inconsistent data if you select a different Treat Source Rows As option and you configure the session for constraint-based loading.

When the mapping contains Update Strategy transformations and you need to load data to a primary key table first, split the mapping using one of the following options:
  • Load primary key table in one mapping and dependent tables in another mapping. Use constraint-based loading to load the primary table.
  • Perform inserts in one mapping and updates in another mapping.

Constraint-based loading does not affect the target load ordering of the mapping. Target load ordering defines the order the Integration Service reads the sources in each target load order group in the mapping. A target load order group is a collection of source qualifiers, transformations, and targets linked together in a mapping. Constraint-based loading establishes the order in which the Integration Service loads individual targets within a set of targets receiving data from a single source qualifier.

Example

The following mapping is configured to perform constraint-based loading:
 
In the first pipeline, target T_1 has a primary key, T_2 and T_3 contain foreign keys referencing the T1 primary key. T_3 has a primary key that T_4 references as a foreign key.
 
Since these tables receive records from a single active source, SQ_A, the Integration Service loads rows to the target in the following order:
1. T_1
2. T_2 and T_3 (in no particular order)
3. T_4

The Integration Service loads T_1 first because it has no foreign key dependencies and contains a primary key referenced by T_2 and T_3. The Integration Service then loads T_2 and T_3, but since T_2 and T_3 have no dependencies, they are not loaded in any particular order. The Integration Service loads T_4 last, because it has a foreign key that references a primary key in T_3.

Sample Example:
I have an employer file with employee and department data. Where the Department table is primary table and the Employee table is child table. So, I need to load data 1st in Department table and then 2ndEmployee table.
 
Enabling Constraint-Based Loading
When you enable constraint-based loading, the Integration Service orders the target load on a row-by-row basis.
1. Select the session you have created for 'Constraint-Based Loading' and double click on it.
2. Go the Properties tab under General Option, Select the Treat Source Rows As "Insert".
3. Go to the Config Object tab. In the Advanced settings, select Constraint Based Load Ordering.
4. Click 'Apply' and 'OK'.

Note: In Constraint-Based Loading we cannot update data, It is only for the insert.


6 comments:

  1. it was nice article it was very useful for me as well as useful forInformatica learners. thanks for providing this valuable information.

    ReplyDelete
  2. Great Information admin thanks For Your Information and Any body wants
    learn SAS through Online for Details Please go through the LinkSAS(Statistical Analysis System) Online Training 

    ReplyDelete
  3. It is nice article keep it up...and please update the blog for latest and advance Informatica scenarios... it is very use full to Informatica learners.

    ReplyDelete
  4. Nice Article..Really Helpful..

    ReplyDelete
  5. Very nice article ... thanks for sharing your knowledge.

    ReplyDelete