Sequential File | Database Management System

Sequential FileĀ | Database Management System

Sequential File : The most basic way to organize the Collection of records that from a file is to use sequential organization. In a sequentially organized file records are written consecutively when the file is Created and must be accessed consecutively when the file is later used for input.

  • A sequential file maintains the records in the logical sequence of its primary key values.
  • A sequential file can be stored on devices like magnetic tape that allow sequential access.
  • The processing of a sequential file is conceptually simple but inefficient for random access.
  • In this organization records are written consecutively when the file is created. Records in a sequential file can be stored in two ways.

 

 

  • Pile file : Records are placed one after another as they arrive (no Sorting of any kind).
  • Sorted file: Records are placed in ascending or descending values of the primary key.

File reorganization steps are:

  1. read the entire file (all blocks) in RAM.
  2. remove all the deleted records.
  3. Write all the modified blocks at a different place on the disk.

 

(1) inserting a record: To insert a record, it is placed at the end of the file. No need to sort (ascending or descending order) the file.

(2) Deleting or modifying a record: This will require to fetch the block containing the record, find the record in the block and just mark it deleted, then write the modified block to the disk. Total time required; T or T = T + 2r.

(3) Sorted Sequential File: In a sorted file, first the record is inserted at the end of the file and then moved to its correct location (ascending or descending). Records are stored in order of the values of the key field.

Advantages of Sequential File Organization

  1. Good for report generation, Statistical computation and inventory control.
  2. It is fast and efficient when dealing with large volumes of data that need to be processed periodically (batch system).
  3. Simple file design.
  4. Very efficient when most of the records must be processed e.g., Payroll.
  5. Very efficient if the data has a natural order.
  6. Can be stored on inexpensive devices like magnetic tape.

Disadvantages of Sequential File Organization

  • Requires that all new transactions be sorted into the proper sequence for sequential access processing.
  • Locating, storing, modifying, deleting, or adding records in the file require rearranging the file.
  • This method is too slow to handle applications requiring immediate updating or responses.