Direct (Random) Access Files
  Direct access of a record is where the record can be located and retrieved immediately without having to access any other records. The software needs to be able to calculate where the record is stored.

 

 
A Direct Access File is a file where the records are placed at an address arrived at by a calculation performed on a key field. This calculation is called a hashing algorithm.

The computer performs the hashing algorithm on the key field of the record, resulting in an address of a block of backing storage and the computer stores the record in that block.

If that block is already full, then the computer will store the record in an overflow area. A pointer will be left at the original block to indicate that a record is stored in the overflow area.

Eventually the blocks will become full and there will be a large number of records in the overflow areas. When this happens, the file will need to be re-organised to prevent access to records becoming too slow.

Access to records follows the same pattern...

  • use the hashing algorithm on the key to find the address of the block where the record is stored.
  • look for the record at the address. If it is not there follow the pointer to the overflow area.

Access to records is extremely fast

A random file would have to be stored on a direct access backing storage medium eg magnetic disc, CD, DVD

Example : Any information retrieval system. Eg Train timetable system.

A direct access file is also called a random access file because it takes the same time to retrieve any record.