Relative File Components
The two main components of a relative file are the side sector chain of blocks
and the data block chain. Both are linked together through forward pointers
similar to those used in a sequential file. Record sizes, while fixed in length,
may range from one to 254 bytes. The number of records is limited to the capacity
of the disk or 65,535 records.
Side Sectors – The side sectors do not contain record information, but do
contain locations of the data blocks. The record size dictates where the pointer is
placed when a record numbers is referenced because the record size is used in an
algorithm to compute where the pointer is placed when a record number is given
through the RECORD command. The side sector also contains a table of point-
ters to all of the other side sectors within the file. In order to move from one
side sector to another, the pointer is referenced through the appropriate DOS com-
mand, and the corresponding side track and sector read into memory. By using
the information contained in the referenced side sector, the data block pointer
can be located and used to read in the actual data block containing the record.
The relative file data block pointers in the side sectors allow the DOS to move
from one record to another within two disk read commands-a considerable
savings in the amount of time required to find a desired data block when com-
pared to sequential methods.
A file may contain up to six side sectors and each side sector may contain
pointers to 120 data blocks. Therefore, the largest file on the 2031 Disk would be
182,880 bytes (120 pointers/side sector*6 side sectors*254 bytes/block) which
happens to be larger than the total storage capacity of that particular disk.
Relative File Expansion
To expand a relative file, a programmer may reference the last record number
generated through the RECORD command and print to that particular record.
The intermediate records from the point of the current end of the file to the
reference record number will be automatically generated by the DOS. This
includes any side sectors and all data b locks necessary to contain a file, regard-
less of size, but within the capacity limits of the diskette. For example, if the
current size of the relative record is one data block long and the record number
referenced would expand it to 125 block, then an additional side sector would
be generated by the DOS since one side sector can only represent 120 data
blocks. See the paragraph entitled “EXPANDING A RELATIVE FILE” for
more information and an example program.
Spanning is a key feature of relative files which aids in reducing the number of
disk read/write operations required to find and retrieve data. Before explaining
how this feature improves time utilization efficiency, we need to examine how
I/O channels are utilized by relative files.
61