INDEX Data Dictionary File
Field |
Description |
Type |
Comments |
FILE_ID |
File alias (key) |
C(16) |
|
INDEX_ID |
Index Name |
C(16) |
Indices are accessed in applications by name. |
FIELD_ID |
Field ID |
C(16) |
Field ID that matches this segment, if this segment is dependent on field. |
KNUM |
PRO/5 KNUM/Type |
U(1) |
PRO/5 MKEYED KNUM for this index, or a flag indicating an external file type: 0..15 ($00$ .. $0F$) MKEYED KNUM ($80$)+ External File |
SEQ |
Concat. Sequence |
U(1) |
Segment number within this index. |
NUM |
Field Number |
U(2) |
Physical field number, based on MKEYED FIN() rules (delimited by $0A$ characters). |
OFFSET |
Segment Offset |
U(2) |
Byte offset within the field, based on MKEYED FIN() rules. Offset is zero-based. |
LENGTH |
Segment Length |
U(2) |
|
ATTR |
Index Attributes |
U(1) |
Attribute bits (additive): $01$ Descending sort $02$ Unique key/segment |
DESCR |
Description |
C(128) |
Description of this segment. |
PATH |
External File |
C(128) |
Reserved |
SELECT |
Select Clause |
C(128) |
Reserved |
ACCESS |
Access Method |
C(128) |
Reserved |
KNUM |
Index Name |
Field(s) |
0 |
INDEX00 |
FILE_ID+INDEX_ID+SEQ |
1 |
INDEX01 |
FILE_ID+KNUM+SEQ |
2 |
INDEX02 |
FILE_ID+FIELD_ID |
3 |
FILE |
FILE_ID |
4 |
FIELD |
FIELD_ID |
5 |
INDEX |
INDEX_ID |
Dependent Indices
Dependent indices make the best use of the data dictionary. A dependent index is defined in terms of fields in the record. For example, the segments that make up the dependent indices for the INDEX file are:
INDEX_ID = INDEX KNUM = $00$
SEQ |
FIELD_ID |
FIELD_NO |
OFFSET |
LENGTH |
ATTR |
$00$ |
FILE_ID |
1 |
0 |
16 |
$00$ |
$01$ |
INDEX_ID |
1 |
16 |
16 |
$00$ |
$02$ |
SEQ |
1 |
33 |
1 |
$00$ |
INDEX_ID = KNUM KNUM = $01$
SEQ |
FIELD_ID |
FIELD_NO |
OFFSET |
LENGTH |
ATTR |
$00$ |
FILE_ID |
1 |
0 |
16 |
$00$ |
$01$ |
KNUM |
1 |
32 |
1 |
$00$ |
$02$ |
SEQ |
1 |
33 |
1 |
$00$ |
INDEX_ID = FIELD KNUM = $02$
SEQ |
FIELD_ID |
FIELD_NO |
OFFSET |
LENGTH |
ATTR |
$00$ |
FIELD_ID |
1 |
34 |
2 |
$00$ |
Independent Indices
Independent indices are PRO/5 MKEYED file segments (specified in a PRO/5 MKEYED statement in the format [1:1:3]+[2:3:3]). This format means [(field):(offset+1):(length)]. The data dictionary stores similar Independent Index information as:
FIELD_NO |
Physical field number within the record, or 0 to base this segment on the entire record. |
OFFSET |
Offset within that field (zero-based). PRO/5 MKEYED segments use byte position (offset+1). |
LENGTH |
Length of this segment. |
The INDEX file stores each key SEGMENT in a different record, so an MKEYED key of three segments is stored in three INDEX records. For example, consider the following MKEYED statement:
MKEYED "TEST",[1:1:6]+[2:10:4],[1:1:6:"D"],0,32
The key segment information for this file is stored in the INDEX file as three records, all with FILE_ID = "TEST". FIELD_ID for each of these is FILL(16), because none of the segments are dependent on a field.
INDEX_ID = INDEX0 KNUM = $00$
SEQ |
FIELD_ID |
FIELD_NO |
OFFSET |
LENGTH |
ATTR |
$00$ |
FILL(16) |
1 |
0 |
6 |
$00$ |
$01$ |
FILL(16) |
2 |
9 |
4 |
$00$ |
INDEX_ID = INDEX1 KNUM = $01$
SEQ |
FIELD_ID |
FIELD_NO |
OFFSET |
LENGTH |
ATTR |
$00$ |
FILL(16) |
1 |
0 |
6 |
$01$ |
External Indices
An existing alias name as the name for an index can be entered in the data dictionary. This establishes a foreign key relationship between the current file and the external file. For example, with a sort file alias defined in the data dictionary as CUST_SORT, an external index for the CUSTOMER alias with the name CUST_SORT could be defined.
Relations
The data dictionary routine that establishes relations between files works through finding identically named fields or indices. It is important to keep this in mind when building an index structure. Always give related indices identical names to detect relations between files.