Previous Topic: RelationshipsNext Topic: Sets


Records

A record occurrence (or simply a record) is the basic addressable unit of data using navigational DML. It consists of a fixed or variable number of bytes of data subdivided into units called elements or fields. Every occurrence of a record is described by a record type defined in a schema, the logical description of a database. All records of the same type contain the same elements arranged in the same order.

For example, John Done's record consists of eleven items including employee ID, first name, last name, address, phone number, status, social insurance number, start date, termination date, and birth date. June Moon's record also consists of the same eleven items.

In COBOL, the EMPLOYEE record might be expressed as follows:

01  EMPLOYEE.
    02 EMP-ID                          PIC 9(4).
    02 EMP-NAME.
       03 EMP-FIRST-NAME               PIC X(10).
       03 EMP-LAST-NAME                PIC X(15).
    02 EMP-ADDRESS.
       03 EMP-STREET                   PIC X(20).
       03 EMP-CITY                     PIC X(15).
       03 EMP-STATE                    PIC XX.
       03 EMP-ZIP.
          04 EMP-ZIP-FIRST-FIVE        PIC X(5).
          04 EMP-ZIP-LAST-FOUR         PIC X(4).
    02 EMP-PHONE                       PIC 9(10).
    02 STATUS                          PIC XX.
    02 SS-NUMBER                       PIC 9(9).
    02 START-DATE.
       03 START-YEAR                   PIC 99.
       03 START-MONTH                  PIC 99.
       03 START-DAY                    PIC 9(4).
    02 TERMINATION-DATE.
       03 TERMINATION-YEAR             PIC 99.
       03 TERMINATION-MONTH            PIC 99.
       03 TERMINATION-DAY              PIC 9(4).
    02 BIRTH-DATE.
       03 BIRTH-YEAR                   PIC 99.
       03 BIRTH-MONTH                  PIC 99.
       03 BIRTH-DAY                    PIC 9(4).

The record definition enables an application program to identify and locate each element in a record occurrence. For example, having retrieved John Done's record occurrence you know that its type is EMPLOYEE. Within EMPLOYEE, the first element in the record is the employee's identification and the last element their birth date.