Key-sequenced data sets
In a key-sequenced data set, logical records are placed in the data set in ascending collating
sequence by a field, called the key. Figure 1 shows that the key contains a
unique value, such as an employee number or invoice number, that determines the record's collating
position in the data set.
The key must be in the same position in each record, the key data must be contiguous, and each record's key must be unique. After it is specified, the value of the key cannot be altered, but the entire record can be erased or deleted. For compressed data sets, the key itself and any data before the key will not be compressed.
When a new record is added to the data set, it is inserted in its collating sequence by key, as
shown in Figure 2.
Table 1 lists the operations and types of access for processing key-sequenced
data sets.
Operation | Sequential Access | Direct or Skip-Sequential Access |
---|---|---|
Loading the data set | Yes | No |
Adding records | Yes (records must be written in key sequence) | Yes (records are added randomly by key) |
Retrieving records | Yes (records are returned in key sequence) | Yes (by key) |
Updating records | Yes | Yes |
Deleting records | Yes | Yes |