User guide

Connecting Record Descriptions to Form New Relationships
Developing an ENFORM Query
058058 Tandem Computers Incorporated 3–19
If you need to see all of the data stored for a particular record description, you can
specify that record description on the left side of a LINK OPTIONAL statement. For
example, suppose that you want a report that lists all of the orders for your company,
all the employees who took the orders, and the region to which those employees
belong. The specifications for this query might appear as follows:
OPEN order, employee, region;
LINK order.salesman TO OPTIONAL employee.empnum;
LINK employee TO OPTIONAL region VIA regnum;
LIST ordernum, empname, regname;
A sketch of the links in the preceding query appears as follows:
order employee region
The report produced by this query is:
ORDERNUM EMPNAME REGNAME
-------- ------------------ ------------
21 GEORGE FORSTER EAST
25 JONATHAN MITCHEL WEST
30 MARTIN SCHAEFER GERMANY
32 TOM HALL EAST
... ... ....
122 OTTO SCHNABL GERMANY
149
Notice that the report entry for order number 149 contains neither a salesman name
nor a region name. This type of entry often provides a clue that the data stored within
your data base is inconsistent. For example, the entry in the preceding report could be
caused by a data entry error in either the data file associated with the order record
description or the data file associated with the employee record description.
To check the consistency of data within your data base, you can produce an exception
report. Such a report discovers inconsistencies between the data stored for two or
more record descriptions. For example, suppose that you want to check the validity of
the region numbers entered in the employee record occurrences. Since you are
verifying the region numbers in employee, you must link employee to region with a LINK
OPTIONAL statement. By specifying a WHERE clause, you can request a report that
lists only those employees whose region numbers are invalid. The specifications for
this query might appear as follows:
OPEN employee, region;
LINK employee TO OPTIONAL region VIA regnum;
LIST empname, employee.regnum,
WHERE employee.regnum <> region.regnum;
A sketch of the links in the preceding query appears as follows:
employee region