The three data portion field types
You can define three field types in the data portion of a segment: a sequence field, data fields, and for variable-length segments, a size field stating the length of the segment.
The first two field types contain your data, and an application program can use both to qualify its calls. However, the sequence field has some other uses besides that of containing your data.
You can use a sequence field, often referred to as a key, to keep occurrences of a segment type in key sequence under a given parent. For example, in the database record shown in the following figure, there are three segment occurrences of the STUDENT segment, and the STUDENT segment has three data elements.

Suppose you need the STUDENT segment, when stored in the database, to be in alphabetic order by student name. If you define a field on the NAME data as a unique sequence field, IMS stores STUDENT segment occurrences in alphabetical sequence. The following figure shows three occurrences of the STUDENT segment in alphabetical sequence.

When you define a sequence field in a root segment of a HISAM, HDAM, PHDAM, HIDAM, or PHIDAM database, an application program can use it to access a specific root segment, and thus a specific database record. By using a sequence field, an application program does not need to search the database sequentially to find a specific database record, but can retrieve records sequentially (for HISAM, HIDAM, and PHIDAM databases).
You can also use a sequence field in other ways when using the IMS optional functions of logical relationships or secondary indexing. These other uses are discussed in detail in other sections.
The important things to know now about sequence fields are that:
- You do not always need to define a sequence field. This information describes cases where a sequence field is necessary.
- The sequence field value can be defined as unique or non-unique.
- The data or value in the sequence field is called the
key
of the segment.