Thursday, March 14, 2013

Informatica Scenario Based Questions with Answer - Part 4

Take a look at the following tree structure diagram. From the tree structure, you can easily derive the parent-child relationship between the elements. For example, B is parent of D and E.

The above tree structure data is represented in a table as shown below.

c1, c2, c3, c4
A, B, D, H
A, B, D, I

Here in this table, column C1 is parent of column C2, column C2 is parent of column C3, column C3 is parent of column C4.

Q1. Design a mapping to load the target table with the below data. Here you need to generate sequence numbers for each element and then you have to get the parent id. As the element "A" is at root, it does not have any parent and its parent_id is NULL.

id, element, parent_id
1, A, NULL
2, B, 1
3, C, 1
4, D, 2
5, E, 2
6, F, 3
7, G, 3
8, H, 4
9, I, 4

I have provided the solution for this problem in Oracle Sql query. If you are interested you can Click Here to see the solution.

Q2. This is an extension to the problem Q1. Let say column C2 has null for all the rows, then C1 becomes the parent of C3 and c3 is parent of C4. Let say both columns c2 and c3 has null for all the rows. Then c1 becomes the parent of c4. Design a mapping to accommodate these type of null conditions.

No comments:

Post a Comment