Visual Queries
Vision applications query an Ingres database to retrieve, change, or input data. Vision generates the code for frames as a visual query that defines how the frame accesses the database.
Note: A visual query is also called the frame definition, and the process of specifying the query is referred to as defining the frame. These terms are used interchangeably in this guide.
Use the Vision Visual Query Editor to see the visual query. The following figure illustrates a visual query display window:
With the Visual Query Editor, you complete the following tasks:
• See the tables and columns used in a query.
• Indicate which columns to join for multi-table queries.
• Designate the columns to display as fields on the form.
• Assign values for specific fields or specify restrictions on the data retrieved by the query.
• Include Lookup tables in your queries to provide additional data to the user.
For information on how to use the Visual Query Editor to customize visual queries, see
Defining Frames with Visual Queries. For basic information about formulating Ingres queries, see the
Forms-based Querying and Reporting Tools User Guide.Joining Tables
Often the data you need for a query is located in more than one table. Ingres lets you join the tables that contain the information you need. This lets you combine data without having to include the same data in more than one table. The following figures demonstrate how two Ingres tables are joined. The Orders table contains information about each order; the Order_items table provides details about items to be ordered.
Assume you want to find how many of a certain part were ordered on a specific date. This information is not all available from one table. Your query needs to retrieve:
• All order numbers with that date from the Orders table
• The part number and quantities in the Order_items table with the order numbers that you retrieved from the Orders table
Join the tables on a column they have in common. This common column is referred to as the join column. In the example, the "order_no" (order number) column is the join column. You use the Visual Query Editor to specify the join columns. As illustrated in the Visual Query Editor above, Vision marks these columns so you can see how your tables are joined.
For more information about joining tables, see Character-based Querying and Reporting Tools User Guide. You may have used QBF already to specify join definitions (JoinDefs) for your tables. The concept of joining tables in Vision is identical, although the way you specify them is different.
Master and Detail Tables
In the previous example, each order appears once in the Orders table. The Order_items table, however, can contain many items that are part of a specific order. These tables are said to have a "one-to-many relationship."
In Ingres, tables that are related in this way are called master and detail tables. In the example, Orders is the master table and Order_items is the detail table.
When you use Vision to create a frame, you specify the master table. A detail table is optional.
Lookup Tables
A frame can have only one master table and one detail table, but you can include data from other tables by specifying these tables as Lookup tables.
Lookup tables are regular Ingres tables that generally contain information that is relatively fixed, such as part numbers or customer names and addresses.
When you include a Lookup table in a visual query, you specify how to display its data to the user. The part of the Lookup table that the user sees is called a selection list, because the application presents a list from which the user selects an item.
Selection lists are illustrated in
Getting Started (see
Getting Started in Vision). For a detailed explanation of how your applications can use selection lists, see
Vision Applications from a User’s Perspective.
Last modified date: 01/30/2023