Target Load Order Constraints
A target load order constraint restricts how the Data Integration Service loads and commits rows to two target instances related to each other in the same mapping.
In the Developer tool you can configure constraints to restrict the order that the Data Integration Service loads rows to target tables.
You can configure a constraint to force the Data Integration Service to load the data of a primary target instance completely before loading data to a secondary target instance. The tables that you define as the primary target and secondary target depend on the transactions in the input rows.
Consider the following scenarios for target load order constraints:
- Insert rows to a master and a detail target.
- You might configure a target load order constraint when you are inserting rows to targets that have a primary key-foreign key relationship. Configure the target with the primary key as the primary target instance. Configure the target with the foreign key as the secondary target instance. The Data Integration Service can stage the data for the secondary target until it completes loading the primary target.
- Delete rows from a master and a detail target.
- When you need to delete rows from targets with a primary key-foreign key relationship, you configure a different constraint. Configure the target with the foreign key as the primary target instance to delete the rows from the detail target first. Configure the target with the primary key as the secondary target instance.
- Insert rows and update rows to the same relational table.
- You can configure a target load order constraint for a mapping that loads insert rows and update rows to a relational table from two separate transformations. Configure the constraint to restrict the Data Integration Service from loading the update rows until after it loads the insert rows.
- Target load order for flat files.
- You can configure a target load order constraint for a mapping that loads rows into multiple flat file targets. Configure the target load order to load the secondary flat file after the primary flat file.
You can configure multiple constraints in a mapping. The Data Integration Service determines the most efficient execution plan to load the targets without violating the constraints.
Constraints with Insert and Delete Rows
Target load order constraints do not have special handling to process insert, update, and delete rows in the same file.
When you need to process insert, update, and delete rows, you can configure a Router transformation to return the insert and update rows to a different target instance than the delete rows. Configure target load order constraints to specify the order in which to load the targets.
For example, you might have an Order_Header and an Order_Detail target. The Order_Detail table has an OrderID foreign key to the Order_Header table. You need to process inserts, updates, and deletes in both tables.
You can separate the insert and update rows from the delete rows using a Router transformation. You configure the following output groups from the Router transformation:
- 1. Order_Header insert and update rows
- 2. Order_Header delete rows
- 3. Order_Detail insert and update rows
- 4. Order_Detail delete rows
You might create the following constraints for loading these rows to the targets:
Group #4 before group #2
Group #2 before group #1
Group #1 before group #3
These constraints force the Data Integration Service to process the deletes in the Order_Detail before the deletes in the Order_Header. The Data Integration Service processes all the deletes before the insert and update rows. It processes the Order_Header inserts and updates before the Order_Detail inserts and updates.
Target Load Order Rules and Guidelines
Consider the following rules and guidelines when you define target load order constraints:
- •In the Developer tool, you can configure some target columns as primary keys or foreign keys. Load order constraints ignore these keys. If the targets have primary key-foreign key constraints, you must define the load order constraints.
- •The Developer tool does not validate the load order constraints as you define them. The Developer tool validates the load order constraints as it validates the mapping.
- •The Data Integration Service can stage the data to a local disk for the second target instance in a target load order constraint. When the mapping has multiple secondary target instances, the Data Integration Service loads the staged data to the targets without violating the constraints.
- •The Data Integration Service loads one target instance and then another target instance without determining whether the rows are inserts, deletes, or updates. For target tables with primary-key foreign-key constraints, an orphan row is a row in the foreign key target that does not have a matching row in the primary key target. The Data Integration Service does not check for orphan rows. The Data Integration Service loads all of the rows in the order you specify in the load order constraint.
WARNING: Informatica strongly advises against using the staging files or the data within the files. Informatica is not responsible for corrupted data that is caused by customer alteration of the staging files or the data in the tables. The structure of the staging files might change between Informatica versions.
Target Load Order Example
An organization processes customer orders twice a day. It receives the customer information and order information in the same transaction file. The organization needs to ensure that the mapping that processes the order file loads the customer information before it loads the orders.
A developer creates a mapping that returns the customer information to a Customer_Target table. The mapping returns the orders to an Orders_Target table. The primary key of the Customer_Master is the CustomerID. Each order in the Orders table has a foreign key to the CustomerID in the Customer_Master. The developer creates a target load order constraint. The constraint restricts the Data Integration Service from loading the orders until the it completes loading the customer information to the target.
The following image shows the mapping:
A Normalizer transformation creates separate output groups for the customer and orders data. The developer needs to ensure that the customer data loads to the target before the orders data.
The Data Integration Service can use different strategies to implement the target load order constraint. In this example, the Data Integration Service creates two pipelines to load the customer data and the order data to the target tables.
The following image shows the pipelines that load the customer data and the order data to the target tables:
In the first pipeline, the Data Integration Service loads the customers to the Customer_Master and it stages the orders to a local disk file. In the second pipeline, the Data Integration Service loads the staged orders to the Orders table.