HPlogo KSAM/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 1 INTRODUCING KSAM/3000

KSAM/3000 FEATURES

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

KSAM/3000 provides a number of features beyond the standard indexed sequential access method.

These include:

  • Multiple Keys

  • Duplicate Key Values

  • Retrieval by Generic Key

  • Retrieval by Approximate Match

  • Fixed or Variable Length Data Records

MULTIPLE KEYS

Each data record can contain from one to sixteen keys. Of these keys, one is required, called the primary key; any others are alternate keys. For example, in an employee record, the primary key could be the employee's social security number; alternate keys might be the employee's name, phone number, or zip code. The values in these key fields determine the orders in which data records are sequenced.

PRIMARY KEY. One field in each data record is defined to contain the primary key. The value in this field determines the primary sequence of records in the data file. Records are sequenced according to this primary key unless sequencing by an alternate key or inchronological order is specifically requested.

ALTERNATE KEYS. Other fields within each data record can be designated as alernate keys to be used for alternate sequencing of records. Up to 15 alternate keys can be designated for each record, however, each additional alernate key adds to the overhead and can affect performance when accessing and maintaining a file. The file can be sequenced in a different order for each alternate key defined for the file.

Note that alternate keys bear no hierarchical relation to each other or to the primary key. Each key is ordered in sequence by its value and type with no relation to other keys. In KSAM, sequence always means ascending sequence according to the ASCII collating sequence, (refer to appendix C.)

DUPLICATE KEYS

Sometimes it is essential that key values be unique (for example, a social security number), and at other times duplicate key values should be allowed (for example, a zip code). To provide for both cases, KSAM allows you to declare that any key may have a duplicate value while disallowing duplicate key values as the default condition. Allowing or disallowing duplicate key values applies to both primary and alternate keys. Duplicates can be allowed for one or more keys while being disallowed for other keys.

NOTE: Duplicate keys can greatly increase the time required to load or access a record with a duplicated key value. This is particularly true when there are a large number of duplicated key values in a large file. As a result, duplicate keys should only be used when other methods are not practical. For example, you should not make a key of an item that can only have two values, as "MALE" or "FEMALE."

GENERIC KEYS

During retrieval by key value you can choose to use part of a key rather than the entire key. Called generic keys, such partial keys allow you to retrieve a set of records whose key values differ in their entirety but share a common value at the beginning. Generic keys must begin at the first character of the defined key held and be shorter, not longer, than the defined key length; also, the key type must be BYTE, INTEGER, or DOUBLE. Suppose a key field containing a zip code is defined as five characters long. By specifying only the first three characters for retrieval it is possible to read all records whose zip code begins with a particular group of numbers.

NOTE: Generic keys cannot be used when accessing KSAM files through RPG.
[f0101a]

APPROXIMATE MATCH

When retrieving by key value, you can specify that the key you are looking for have a value that exactly matches a specified value, or you can specify that it bear a certain relation to a specified value. The choices are: equal to, equal to or greater than, or greater than. The last two relations let you search for an approximate match. For example, you can retrieve all records with a date greater than or equal to a given date:

[f0101b]

DATA RECORD FORMAT

Every key entry in the key file contains, in addition to the key value, a pointer to the corresponding data record in the data file. The data records can be either fixed length or variable length. If they are fixed, the data record pointer specifies a record number relative to the beginning of the file. If the records are variable length, then the pointer indicates the start of the data record as a word offset from the beginning of the file.

Figure 1-1 A Simplified View of the KSAM File Structure

[A Simplified View of the KSAM File Structure]