Understanding the Query Builder - Intergraph Smart Instrumentation - Help

Intergraph Smart Instrumentation Help

Language
English
Product
Intergraph Smart Instrumentation
Search by Category
Help
Smart Instrumentation Version
13.1

The following topic explains in more detail the Query Builder interface, and how choices made during the query creation effects the data retrieved by the query and the results displayed in the EDE or customized view.

The software uses the information in a query to retrieve specific data from the database, for display as a view or report, at a later time, in the EDE or customized view. By saving your queries in the Reference Explorer you can build up a library that you can access whenever you need. You can use your queries again as templates for creating newer or more specific views and reports.

Select Item Types

After opening the Query Builder or opening an existing query, the first step in creating a query is selecting the required item types for your query from the Item Type Explorer and moving them to the Definition window. There are a number of ways to do this:

  • Drag and drop the required item type to the Definition window.

  • Double click the item type.

  • On an item already displayed in the Definition window:

    1. Right-click the item.

    2. On the shortcut menu select Add relation to > [Select the required item type from the list].

      SHARED Tip The Item Type list that appears, contains only those item types that have a relation with the selected item type in the Definition window.

  • As each item is added to the Definition window you will notice that they are connected by a line with an Relationship DB Icon icon. This shows that the chosen item types have some form of relation. If there is no line then there is no relationship and your query will not work.

  • Not every item type has a Name attribute, for example Connection items. When an item type has a Name attribute and is added to the Definition, the Name attribute is automatically added to the Query Attributes tab.

  • When an item type with no Name attribute is added to the Definition window it is not possible to save the query until an attribute is added to the Query Attributes tab.

Define the Query Definition

For the query to work successfully, you must define the attributes and their relationships that you require. This is done primarily from the Definition window.

Choosing Attributes

Each item type has its own set of categorized attributes. You can choose as many attributes as needed for each item type. When an item type is selected in the Definitions window the available attributes are displayed in the Attribute Explorer and when selected, displayed in the Query Attributes tab.

To choose attributes for an item type:

  1. On the Definition window select an item type, for example Instrument. The Attribute Explorer displays a categorized list of the available attributes for the Instrument item type.

  2. In the Attribute Explorer, from the categorized list select a category.

    SHARED Tip You can also use the Attribute Explorer Search field to type the attribute you are seeking without selecting a category first.

  3. From the selected category, double-click on an attribute, the attribute is added to the Query Attributes tab.

  4. Repeat this process for the remaining item types until you have added all the attributes you want to have in your query.

SHARED Tip You can remove an attribute from the Query Attributes tab by selecting on the QB Remove Attribute button on the attribute

Relationships and Method

It is important to understand how the selected relationship and method effects the final results of your query.

Relationship

In some cases there is only one relationship between the selected Item type, in other instances there may be several relationships to choose from. Examples of a single relationship would be a Terminal Strip > Terminal or Cable > Cable Set. On the other hand, the relationship between an Instrument and a Panel has numerous choices. Some panel types for example would be;

  • Junction Box

  • Device Panel

  • Control System Panel

  • Marshaling Panel

If you have created the definition; Instrument > Panel > Terminal Strip > Terminal, and choose Junction Box as the relationship between the instrument and panel, then when the query runs the software retrieves all those instruments that are connected to junction boxes and retrieves the terminal strips and terminals connected with the junction box. Changing the relationship to another type of panel changes the data retrieved and what is displayed in the EDE.

Method

All the data that is retrieved by the Query Builder is stored in tables within a database. The Method relates to how the software retrieves and displays its data. Within the tables there can be blank records or records in one item with no reference in other selected item type. The method that is selected effects the way the software relates to these blank cells when displaying the retrieved data. There are three methods to choose from:

  • Display only X [Item Type] records and Y [Item Type] records that are related — Displays all the rows where each side of the relationship has data.

  • Display all X [Item Type] records and only those Y[Item Type] records that are related — Displays all the records from row item type X even if there is no relationship to row type Y, but only displays related records from row Y.

  • Display all Y [Item Type] records and only those X [Item Type] records that are related — Displays all the records from row Y even if there is no relationship to row X, but only displays related records from row X.

  • Selecting the correct relationship method is an important factor in your query returning the correct information. Therefore it is recommended that if you are uncertain as to which method to choose, select Display only X [Item Type] records and Y [Item Type] records that are related.

  • When working with complex queries (three or more item types), it is recommended to use the same relationship method for the entire query.

Query Attributes Tab and Query Preview

Other components of the Query Builder window consists of two tabs, Query Attributes and Query Preview.

The Query Attributes tab is where you can find all the attributes that have been selected for your query. Here you can edit the caption name of the attribute, change its position in relation to the other attributes, and determine whether to show or not show the attributes values in the EDE. You can also sort the data displayed in the attribute columns and save the sort criteria to apply to your EDE, when generating.

Sort parameters applied in a query to an attribute's values, that are defined as invisible (Display attribute check box is cleared), are not taken into consideration in the generated EDE. We recommend that if you apply sort parameters to an attribute's values in a query, that the attribute is not defined as invisible. If you do not want to see an attributes values in the EDE report, you can specify which EDE columns to include in the report when printing. For more information, see Print Multi-Header Report from an EDE View.

As the name of the Query Preview tab suggests, here you can see the results of your query, this allows you to check that the report or view that you generate with the EDE contains the correct data and is displayed how you want.