Tables and Joins (Query Builder)
On the Tables and Joins tab, you can add the tables on which to query, and specify the joins between them. You can drag-and-drop tables within the window for ease of viewing. The joins between tables are moved along with the tables. The new position of the tables is saved when you click Apply to save your changes.
From the Tables and Joins tab you can perform the following actions:
Tables
A table can be either a type or subtype in the Windchill database, or an existing report template. Tables are represented on the Tables and Joins tab by rectangular nodes.
The alias for the table displays in the rectangular node. An alias is a substitute name for the table, and is particularly useful when the same type or report template view appears more than once within the query. Other parts of Query Builder that refer to types or report templates always use the alias name. By default, the initial alias for the table is the table’s display name. If the alias for a table is already present in the query, then a number is appended to the alias name to make it unique, for example Document1. Hover over the table rectangle to see the alias and internal type name for the table.
A report template added to a query is known as a report template view. As with standard Windchill types, report template views can be used for creating joins, selecting attributes for inclusion as report output columns, specifying search criteria, and determining sort order. Throughout this help, any reference to types also refers to report template views, unless otherwise stated.
Report template views allow easy reuse of existing reports. If a complex query has already been defined and saved as a report template, it can be reused by including it in another report as a report template view. Report template views can be used to perform nested queries and create complex joins. Report template views can be nested to define more complex queries, similar to SQL nested queries, though multiple levels of nesting can affect performance.
| If a report template is used as a report template view in another report, the report template cannot be deleted. Similarly, a report template column that is referenced from a report template view in another report template cannot be deleted from the original report template until the reference is removed. |
Joins
The relationships between tables are very important. Query Builder enables you to select from the possible relationships between these tables, and specify the relationships that are applicable to the objects being searched. Such a specification is called a join, and the set of possible relationships is determined by the Windchill data model. Joins are represented on the Tables and Joins tab by arrows, with the direction of the arrow showing the direction of the join.
When multiple types are part of a query, each type should be joined. Otherwise, duplicate objects (rows) can be returned in the report output when the report is generated. It is advisable to preview the report using View Report to ensure that the appropriate joins have been created. Each table should have at least one join arrow connecting it to another table.