File Organization and Processing - Chapter 3

Relative File Organization

Within a relative file are numbered positions, called cells. These cells are of fixed equal length and are consecutively numbered from 1 to n, where 1 is the first cell, and n is the last available cell in the file. Each cell either contains a single record or is empty. Records in a relative file are accessed according to cell number. A cell number is a record's relative record number; its location relative to the beginning of the file. By specifying relative record numbers, you can directly retrieve, add, or delete records regardless of their locations. (Detecting deleted records is only available if you specified the -vms (Linux and Mac OS) or /vms (Windows) option when the program was compiled.)
***When creating a relative file, use the RECL value to determine the size of the fixed-length cells. Within the cells, you can store records of varying length, as long as their size does not exceed the cell size.

Indexed Files

Indexed files may have up to 255 keys, the keys can be alphanumeric and only the primary key must be unique. In addition, it is possible to read an Indexed file sequentially on any of its keys. An Indexed file may have multiple keys. The key upon which the data records are ordered is called the primary key. The other keys are called alternate keys.
Records in the Indexed file are sequenced on ascending primary key. Over the actual data records, the file system builds an index. When direct access is required, the file system uses this index to find, read, insert, update or delete, the required record.
An Indexed file may have multiple, alphanumeric, keys. Only the primary key must be unique. For each key specified for an Indexed file, an index will be built.