Index Creation
The creation of an index is transparent to application programs. An index is created according to your specifications, but the actual creation and storage of the index is performed by CA IDMS/DB. An index is composed of SR8 system record occurrences chained (by next, prior, and owner pointers) to the owner occurrence and each other.
SR8 Records in an Index
Thus, an index is a chained set between the indexed set's owner record and the SR8 records. An index contains SR8 records chained by next, prior, and owner pointers to the indexed set's owner record. For simplicity, prior and owner pointers are not included in the next figure):

Initially, the index is composed of a single SR8 member record. When the first SR8 record is full, additional SR8 records are added to the index as chained records.
Bottom-Level SR8 Record and Database Record Occurrences
An SR8 record, shown in the following diagram, contains from 3 to 8,180 index entries (as specified in the schema or segment definition) and a cushion (that is, a field the length of the largest possible index entry).
The SR8 record in the diagram contains four entries and a cushion. Each index entry contains an index pointer that points to a database occurrence that is a member of the indexed set; each member occurrence contains an index pointer that points to that SR8 record. (Note that, for simplicity, prior and owner pointers are not included in this figure.)

Content of an Index Entry
The actual content of an index entry depends on the indexed set's characteristics, as follows:
Example
In this example, there is a single SR8 record chained to the indexed set's owner. The SR8 record contains three entries. Each entry contains an index pointer that points to a member database occurrence; each member occurrence contains an index pointer that points to that SR8 record. Additionally, the member occurrences contain owner pointers that point back to the set's owner.

Indexed Set with Sorted Set Order
For sorted indexed sets, you can specify that CA IDMS/DB keep the index entries within the SR8 records in ascending, descending, or mixed order according to the member record's db-key or symbolic key. You can also specify whether numeric fields should be collated so that negative values are lower than positive values (natural sequence) or whether they should collate based on their bit pattern. If you specify that an indexed set be sorted on symbolic key, you can also specify whether duplicate symbolic keys are allowed or disallowed. Even if you specify that duplicate symbolic keys are allowed, CA IDMS/DB does not store the same symbolic key more than once in the index. For example, the first time a record with a symbolic key ADAMS is added to the indexed set, CA IDMS/DB adds the symbolic key ADAMS to the index and associates the record occurrence's db-key to the key ADAMS. Later, if you add another record with the symbolic key ADAMS to the indexed set, CA IDMS/DB associates the db-key of the new record to the existing symbolic key of ADAMS in the SR8 record.
Specifying Compression
Additionally, you can specify that CA IDMS/DB store symbolic keys in either compressed or uncompressed format. (Note that CA IDMS/DB always strips trailing pad characters from an indexed set's symbolic keys.) If you specify compression, CA IDMS/DB applies a 2-level compression algorithm to the symbolic key before inserting the key into the index, as follows:
Specify compression of symbolic keys if the keys have either of the following characteristics:
How the Index is Organized
To facilitate the process of locating an index entry for sorted sets, CA IDMS/DB organizes an index for sorted records into levels. In this case, when the first (top-level) SR8 record is full, CA IDMS/DB performs the following processing:
CA IDMS/DB repeats this process as the index expands. Indexes can have any number of intermediate levels. As CA IDMS/DB adds new entries, it splits SR8 records and spawns new levels of SR8 records. An entry on one level points to an SR8 record at a lower level; the bottom-level entries point to the indexed database records themselves.
Therefore, in a sorted indexed set with three levels (top, intermediate, and bottom), the index is structured as follows:
The bottom level is made up of one SR8 record for each entry in the intermediate level. Each entry is composed of a symbolic key and a pointer to a database record occurrence.
Example
For example, the sample database includes the indexed set EMP-LNAME-NDX. The EMP-LNAME-NDX set, shown in the following diagram and table shows the function of index levels and the search process. This simple index contains only three entries per SR8 record. The figure represents index and database records. (For simplicity, prior and owner pointers are not included in this figure.) The table shows the index pointers and symbolic keys.
To locate LONG in this 3-level index, CA IDMS/DB performs the following steps:
Note: For SQL-defined indexes, it uses a CALC key based on a number assigned to each index.
Note: Since previous processing deleted indexed records, not all of the index entries in each SR8 record are presently used (for instance, the STUART and UPTON/WEST SR8 records at the bottom level). Consequently, this index has space for expansion without spawning a new level.

In this example, each SR8 record is composed of a maximum of three entries. Each entry is composed of a symbolic key value and a db-key. The shaded entries are used to locate the LONG record in the database. In the top and intermediate levels, the db-key in each entry points to another SR8 record. In the bottom level, the db-key in each entry points to a database record. (Note that, for simplicity, prior and owner pointers are not included in this figure; also, since two employees are named BENN, there are two database member occurrences with that name.)
The entries in the 3-level index are shown next. Each entry is composed of a symbolic key and a db-key. The shaded entries are used to locate the LONG record in the database. The index entries in the top and intermediate levels point to SR8 records at the next lowest level. Only the bottom-level entry points to the database record. Note that since two employees are named BENN, there are two db-keys (one to each database member occurrence) for that symbolic key.
|
|
SR8 db-key |
SR8 Index Entries |
|
|---|---|---|---|
|
Top level SR8 records |
90002:3 |
Innis |
90004:10 |
|
Intermediate level SR8 records |
90004:10 |
Carr |
90015:13 |
|
|
90004:57 |
Nelson |
90021:3 |
|
Bottom-level SR8 records |
90015:13 |
Benn |
721009:147 |
|
|
90016:40 |
Davis |
720617:201 |
|
|
90030:6 |
Grey |
720016:31 |
|
|
90021:3 |
James |
726412:4 |
|
|
90018:53 |
Stuart |
720039:37 |
|
|
90030:12 |
Upton |
720715:52 |
|
Copyright © 2014 CA.
All rights reserved.
|
|