How a HISAM record is stored

HISAM database records are stored in two data sets: a primary data set and an overflow data set.

The primary data set contains an index and all segments in a database record that can fit in one logical record. The index provides direct access to the root segment (and therefore to database records). The overflow data set, contains all segments in the database record that cannot fit in the primary data set. A key-sequenced data set (KSDS) is the primary data set and an entry-sequenced data set (ESDS) is the overflow data set.

There are several things you need to know about storage of HISAM database records:

The following figure shows four HISAM database records.

Figure 1. Example HISAM database records
SKILL1 has NAME, EDUC, and EXPR dependent segments. SKILL2 has 2 NAME, one EXPR, 2 salary, and 3 EDUC dependent segments. SKILL3 and SKILL4 have no dependents.

The following figure shows the four records from the preceding figure as they are initially stored on the primary and overflow data sets. In storage, a HISAM segment consists of a 2-byte prefix followed by user data. The first byte of the prefix is the segment code, which identifies the segment type to IMS. This number can be from 1 to 255. The segment code is assigned to the segment by IMS in ascending sequence, starting with the root segment and continuing through all dependents in hierarchical sequence. The second byte of the prefix is the delete byte.

Figure 2. Example HISAM database records in storage
Index has pointers for SKILL2 and SKILL4. CIs have two logical records. One CI has roots SKILL1 and SKILL2. Other CI has SKILL3 and SKILL4. Last segment in logical record points to overflow data set.

Each logical record in the primary data set contains the root plus all dependents of the root (in hierarchical sequence) for which there is enough space. The remaining segments of the database record are put in the overflow data set (again in hierarchical sequence). The two parts of the database record are chained together with a direct-address pointer. When overflow segments in a database record use more than one logical record in the overflow data set, as is the case for the first and second database records in the preceding figure, the logical records are also chained together with a direct-address pointer. Note in the figure that HISAM indexes do not contain a pointer to each root segment in the database. Rather, they point to the highest root key in each block or CI.

The following figure illustrates the following points regarding the structure of a logical record in a HISAM database:

Figure 3. Format of a logical record in a HISAM database
4-byte relative byte address is followed by segments and then a segment code of 0. After segment code is unused space.