


A frequent application is to represent two tables that are connected by a foreign key and that are in a 1:N relation in master-detail form.
The master row corresponds to a row of the referenced table while the associated detail rows come from the referencing table.
Example:
The tables customer and reservation are defined as follows:

The following example represents the reservations (detail) for each customer row (master).

With the keys
~and
the previous or the next customer row and the associated reservation rows are fetched simultaneously. The BACKGROUND option of the REPORT
display refreshes the reservation rows, and REPORT returns the control immediately to SQL-PL.
If the user wants to scroll in the report of the reservation rows, the
key must be pressed. By this means REPORT is called in such a way that it maintains the control (without
BACKGROUND option).
Apart from this master-detail representation controlled by SQL-PL, it is also possible to allow the master and detail rows to be controlled completely by REPORT.
This is illustrated by the following example:

This REPORT call provides the same facilities as the SQL-PL routine in the example above.
The reference name, which must be specified after the keywords FOREIGN KEY, corresponds to the <referential constraint name> of the <referential constraint definition> (cf. ADABAS Reference Manual <create table statement>).
If the <referential constraint name> has not been specified explicitly with the table definition, ADABAS implicitly generates the name from the names of the master and detail tables.


