In DBMS, file organization decides how records are laid out on disk. One of the most natural ways to store records is in sorted order using a sequential file.
A sequential file is a file organization where records are stored in an ordered sequence, usually sorted by some search key (like a primary key or a commonly used attribute). Because of this ordering, records are accessed in a linear, sequential manner when scanned from start to end.
What Is a Sequential File?
A sequential file is also called an ordered file. In this organization:
Records are arranged in ascending or descending order of a chosen key.
The physical order of records on disk matches (or closely approximates) the logical order of the key.
For example, if a table is stored as a sequential file on attribute emp_id, then the records appear in increasing order of employee ID, and the DBMS can traverse the file from the first to the last record in key order.
How Insertion Works in a Sequential File
When a new record is inserted into a sequential file:
The DBMS must find the correct position so that the order of the key is preserved.
To place the record, it may need to shift existing records in the page or block, or
Move records to a new page if shifting is too costly or not possible.
This makes insertion slower and more complex than in a heap file, because the DBMS cannot just append the record at the end; it must maintain the order.
When Sequential Files Are Used
Sequential files are useful when:
Frequent range queries or ordered scans are needed (for example, “find all employees with salary between 40000 and 60000”).
Data is mostly read in sorted order, and ordered access is more common than random access.
The chosen key is stable (rarely changed), so the ordering does not need constant reorganization.
Applications that benefit from sequential files include:
Tables ordered by primary key for natural range scans.
History tables where data is accessed by time or sequence (like logs or transactions).
Advantages of Sequential Files
Fast ordered access:
Scanning records in key order is very efficient, as the DBMS reads the file sequentially.
Good for range queries:
The DBMS can quickly locate the starting point and read a continuous block of records.
Reduced seek time (for sorted data):
Adjacent records in the key are stored close together on disk, improving performance for range scans.
Disadvantages of Sequential Files
Slow insertion and deletion:
Inserting in the middle of the file may require shifting records or page reorganization.
Frequent reorganization may be needed:
Over time, many inserts and deletes can fragment the file or degrade the order, requiring rebuilding the file.
Poor for random access on non‑key attributes:
If the file is ordered by one key, searching by another attribute still requires a scan or extra indexes.
For beginners, a sequential file is like a book with pages in order: it is easy to read from beginning to end or to find a section in the middle, but inserting a new chapter in the middle is messy because the pages must be rearranged.
Summary
A sequential file in DBMS is a file organization where records are stored in sorted order by a search key. This allows efficient ordered access and range queries, but insertion and deletion are slower because the DBMS must maintain the order. Sequential files are ideal for tables frequently scanned in key order but less suitable for highly dynamic tables with frequent random inserts and deletes.