The record access method is dependent upon the physical medium on which the file is stored. Magnetic tape is sequential by its very nature. To read a record you must start at the beginning of the tape and sequentially read each record until you get to the one you want. With disks, of course, random access is possible. It is the same as the difference between audio cassette and audio compact disc. With audio tape you have to start at the beginning and run the tape forward until you get to the song you want to hear. With compact disc you can play the songs in random order or go directly to the track you want to hear.
However, not only must the medium allow for random access to records, but the file itself must support going directly to the record you want to retrieve. This characteristic of the file is called "file organization."
A file, even if it is stored on a magnetic disk or CD-ROM disk, may have a sequential file organization. This records in this kind of sequential file (even though the file is on a medium that allows for direct access) may only be retrieved sequentially.
On the other hand, a file on disk can support random access to records if its file organization is either Direct or Indexed. With Direct and Indexed file organization random record access is achieved by means of a "key field." In our by now well-worn example, your university records are likely to be keyed on your Student ID Number (SSN).
With Direct file organization records are assigned relative record numbers based on a mathematical formula known as a hashing algorithm. For example you input a Student ID Number, a mathematical formula is applied to it, and the resulting value is the value that points to the storage location on disk where the record can be found.
An Indexed file includes a table that relates key values (e.g., Student ID Number) to storage locations of the corresponding records. This table is called the index. It is just like the index of a book where the key value (topic) has a pointer to the storage location (page number) where the information is stored.
|
File Organization |
Supported Record Access |
|---|---|
|
Sequential |
Sequential |
|
Direct |
Sequential or Random |
|
Indexed |
Sequential or Random |