Building a Relationship Structure
It is possible to define a Relationship from the context item that can go either up or down the data structure. ‘Down’ refers to a relationship direction starting from the Item representing the source side of the relationship and following the related content to the related Item. ‘Up’ by contrast refers to a relationship direction starting from the Item representing the related side of the relationship and following the related content to the source Item. It is also possible to set up a recursive structure, such as the Part --> Part BOM --> Part, to reuse the same logic for multiple levels. The following procedures show how to expand the query both up and down for a Part Query and introduces recursion.
Building a Downward Relationship Structure
-
Right-click on the Part Context Item and select Add Related Item --> Using Relationship.
Figure 8.
-
Select the Relationship to include in the structure. In this case, select BOM, check Include Related and click Add.
Figure 9.
The query now looks like the following. Note that the alias ‘Part_1’ is assigned to the related Part Query Element in the list.
Figure 10.
-
Right-click on the Part Context Item and select Add Related Item --> Using Relationship. In this case, Press CTRL+click to select Documents and CAD Documents. Check Include Related.
Figure 11.
-
Right-click on the top Context Item and select Add Related Item --> Using Item Property. Select an Item Property to add to the query structure. In this case, select created_by_id.
Figure 12.
-
Use the following procedure to specify the desired Properties for each new element in the Query Definition:
Note: Optionally, you can also set Order By settings as well.
-
For [created_by_id] User, specify the following properties:
-
Item ID
-
First Name
-
Last Name
-
Login Name
-
For [Relationship] Part CAD, specify the following property:
-
Sequence
-
For [Related] CAD, specify the following properties:
-
id
-
Document Number
-
Name
-
State
-
For [Relationship] Part Document, specify the following property:
-
Sequence
-
For [Related] Document, specify the following properties:
-
id
-
Document Number
-
Name
-
State
-
Change the Alias on the CAD Documents element to “Part CAD”:
-
Right-click on CAD Documents and select Change Alias.
-
Enter Part CAD as the name and click the check mark.
Figure 13.
Figure 14.
-
-
Use the same procedure to change Documents Relationship to Part Document.
-
Use the same procedure to change User Relationship to Part Created By.
Note: Each element on a given level must have a unique alias.
-
Save the Query Definition.
Building an Upward Relationship Structure
-
Right-click on the top Part element and select Add Related Item --> Using Referencing Item.
Figure 15.
-
Select an appropriate Referencing item from the structure. In this case, select Simple MCO Part.
Figure 16.
-
Right-click on the Simple MCO Part element and select Add Related Item --> Using Item Property to select source_id.
Figure 17.
-
Set Selected Properties on the Simple MCO element to:
-
id
-
MCO Number
-
Status
-
Date Originated
-
Save the Query Definition.
Adding a Recursive Call Structure
Recursive structures can reuse sections of the already defined queries. The following example shows how to set up a recursive call for the Part --> Part BOM --> Part relationship structure.
-
Right-click on the top-level Part element and add the Part BOM --> Part structure as shown.
Figure 18.
-
For the BOM element, select the following properties:
-
Sequence
-
Quantity
-
related_id
-
Right-click on the child Part element and select Reuse Query Element Definition.
Figure 19.
-
Select the top-level Part element and click Add.
Figure 20.
-
Save the Query Definition item.