Previous Topic: Sorted and Unsorted RelationshipsNext Topic: Additional Sort Options


Nonsorted Order

If the entity occurrences in the relationship are not to be sorted, you can specify the logical order of child entity occurrences within each occurrence of a relationship. You determine how a new child is placed in a relationship by specifying one of the following orders:

Flexibility

The NEXT and PRIOR orders provide more flexibility than the FIRST and LAST options; the programmer can connect an entity anywhere within the relationship by establishing currency before or after the point of insertion. When the FIRST and LAST options are assigned, the programmer can be certain of the positioning of new entities, regardless of set currency.

Note: The PRIOR and LAST options require prior pointers.

For more information on pointers, see "Linkage" later in this chapter.

Next and prior order example

In the example below, assume that a program is positioned on SANDY SHORE before it stores JUNE MOON in the database. In a relationship defined with the NEXT order, JUNE MOON will be stored after SANDY SHORE. In a relationship defined with the PRIOR order, JUNE MOON will be stored before SANDY SHORE.

Next and prior order example.

First and last order example

Suppose two entities are added in the following order: PETER PLUM, then SANDY SHORE. In a relationship defined with the FIRST order, the entity stored most recently (SANDY SHORE) will be returned first. In a relationship defined with the LAST order, the entity stored first (PETER PLUM) will be returned first.

First and last order example.