Parent Child Relation in User Defined Tables
Set Constraints or Create Parent Child Relation
· The user can create a relation between two Tables.
· Let us consider Table 1 and Table 2, where Table 1 is the Parent table and Table 2 is the Child table.
· In this example, we create a relation between both the tables in such a way that Table 2 must appear when the user Right click on the Items of Table 1.
Step 1: Define Tables.
· User should define new tables as defined in this Example
· While defining the Report, the user has to specify the primary key with the tick in the checkbox.
· With column name, proper Data type and column length, data should be entered. Plant Id, Item and Item Type should be marked as Primary Key.
· Add and Save the table.
· Refer to the image below to add a new table. This is Table 1.
· Create Table 2 as done in the previous example. Plant Id and Item should be marked as Primary Key.
· Data Type and Column Length of the Parent and Child Table must be the same.
· Add and Save the table.
Step 2: Set Constraints.
· Constrain should be set in Table 2 which is the child table.
· Click the Icon next to Table Name to select Table 2.
· Select Table 2 from the list.
· Click on Constraints once the Table is selected to set Constraints.
· The Constraint’s window helps to user to define Primary Key Table and Foreign Key Table.
· In the example, Table 1 is Primary Key Table and Table 2 is Foreign Key Table.
· A Primary key is the first key that is used to identify one and only one instance of an entity uniquely. It cannot be NULL.
· Foreign keys are the column of the table that is used to point to the primary key of another table.
· Click on the New button to set Constraints.
· This window allows to add Primary Key Table only.
· More than one Foreign Key Table can be attached to a single Primary Key Table.
· To select Primary Key Table, click on the Icon after the name.
· Select Table 1 from the list of tables available.
· Foreign Key Table is automatically selected. The foreign key is used to establish a link between data in two columns.
· Add the Items from the right box to the left side box in Table 2.
· User can Tick Bund Rule and also give Menu Order.
· Bind Delete Rule and Bind Update Rule check box helps the user to make changes in the Parent Table which automatically gets changed in Child Table.
· Menu Order is the user when more than one Child Table is attached to Parent Table and Child Table appears in order as defined in the Constraints window.
· Save the Constraints.
· User can create one more level of relation between Table 2 and Table 3.
· In the Second level, the user can give Table 2 as Parent Table and Table 3 as Child Table.
· User can create 3 levels using constraints in User Defined Tables.
· The user has to bring Table 1 into Menu by using similar steps followed in Example like, Custom Menu Design and User Authorization.
· Clear Cache after the changes are made.
Step 3: View Result.
· Go to User Tables --> Table 1. Click on Add icon to enter a table.
· Add the fields in the window.
· Items added in the table can be viewed as follow.
· Click on Item ABCD to get Table 2.
· User can add new rows to Table 2 by clicking on the Add icon.
· Material and Type will be automatically filled since the Constraints are set during Table definition.
· User can add the Item and add the row in Table 2.