A technique for physically arranging the records of a file on secondary storage devices is called file organization. The files are organized on storage media in the following ways:

Organize-Files-on-Storage-Media

1.  Sequential files

The records in sequential file organization are stored in sequence. A sequence means the records are stored one after the other. The records can be retrieved only in the sequence in which they were stored. The principal storage media for sequential files is magnetic tape.

The major disadvantage of sequential access is that it is very slow. If the last record is to be retrieved, all preceding record are read before reaching the last record.

2.  Direct or random files

The records in direct file organization are not stored in a particular sequence a key value of a record is used to determine the location to store the record. Each record is accessed directly without going through the preceding records.

This file organization is suitable for storing data on disk. Direct file organization is much faster than sequential file organization for finding a specific record.

A problem may occur in this type of files known as synonym. The problem occurs if the same address is calculated to store two or more records.

3.  Indexed Sequential files

In indexed sequential file organization, records are stored in ascending or descending order. The order is dased on a value called key. Additionally, indexed file organization maintains an index in a file.

An index consists of key values and the corresponding disk address for each record in the file. Index refers to the place on a disk where a record is stored. The index file is updated whenever a record is added or deleted from the file.

The records in indexed file organization can be accessed in sequential access as well as random access or direct access. The records in this file type require more space on storage media. This method is slower than direct file organization as it requires to perform an index search.