Components > Refining intelligent structure models > Primary and foreign keys
  

Primary and foreign keys

For models that contain a repeating group within a repeating group, an output group can include a column called the primary key. A foreign key is a column in another output group that points to the primary key of the first output group. You identify the relationship between a row in one output group and a row in another output group using the keys.
Before Intelligent Structure Discovery adds keys, you must assign a nested repeating node to its own output group. Intelligent Structure Discovery adds a primary key to the parent and a foreign key to the child group.
The following image shows the model created with the JSON input. The Employees repeating group is highlighted:
The Employees repeating group is highlighted. It is part of a parent output group.
In this model, the Employee group is part of the DepartmentItem output group, the second group displayed in the Table tab.
You can promote a nested group in the Visual Model tab. You can view the primary and foreign keys in the Table tab.
The following image shows the output groups after you promote the Employee group:
The primary key and foreign key nodes are highlighted in the intelligent structure and in the output groups.
Intelligent Structure Discovery generates two separate output groups, the DepartmentItem output group, and the Employee output group.
Intelligent Structure Discovery added a primary key named DepartmentItem_PK to the DepartmentItem output group, and a foreign key named DepartmentItem_PK to the Employee output group.
You can select a different node as the primary key by defining it as a record ID. When you change the record ID, Intelligent Structure Discovery creates a corresponding foreign key in the nested group.