Retrieval Keys

Normally some data items are more important than others. From the values given for these key items you can obtain the values of other data items. In the employees example, the employee number, EMPNUM, gives a concise and unique identification to each employee. Given an employee number, the name and age of the employee can be obtained.

Since people are more likely to remember an employee's name than an employee's number, you might also want to have a way of retrieving the other information about an employee, given his or her name. However, employee names cannot be unique. (In the preceding example, for instance, there are two Smiths.) When the value of the key item is the same in two records, the two key items are said to be duplicates. You must be prepared to process all the duplicates to find the desired employee.

You might also want to retrieve employees in alphabetical order by name. The following DASDL description enables all these things to be done conveniently.

EMPLOYEES DATA SET
 (
  NAME      ALPHA(12);
  AGE       NUMBER(2);
  EMPNUM    NUMBER(6);
 );
EMPNUMKEY SET OF EMPLOYEES KEY(EMPNUM);
NAMEKEY SET OF EMPLOYEES KEY(NAME) DUPLICATES;

The Enterprise Database Server ensures that no two employees can have the same value for employee number (EMPNUM), but allows employees with the same name. Employees can be accessed efficiently in order of employee number or name.

The sets of the Enterprise Database Server are maintained automatically whenever records are added or deleted in their data set. The index sets of the Enterprise Database Server allow random retrieval and logical ordering based on any number of keys, each of which can be composed of one or more key items. Index sets are a very powerful feature, indeed, as is illustrated in the discussion that follows.

The selection of sets in effect identifies which retrievals can be made efficiently. In general, not all possible items and combinations of items can be made retrieval keys, because the expense of updating the data set increases with each set added. Therefore, the database designer must have a fairly good idea of the retrievals that are needed and their relative importance (relative frequency). Appropriate sets must be chosen, keeping in mind the trade-off between retrieval speed and the expense of updating and storing the sets.

If the INDEPENDENTTRANS option is set and the data set is an ordered data set, retrieving the last duplicate key results in a serial search of the duplicates. This serial search can impact performance. The Enterprise Database Server must perform the serial search if a change to an ordered data set record is aborted.