It is the most common type of file. In this type of file:
- A fixed format is used for record.
- All records are of the same length.
- Position of each field in record and length of field is fixed.
- Records are physically ordered on the value of one of the fields - called the ordering field.
Block 1 |
Name |
Roll No |
Year |
Marks |
Amit |
1000 |
1 |
82 |
Kaplesh |
1005 |
2 |
54 |
Jitendra |
1009 |
1 |
75 |
Ravi |
1010 |
1 |
79 |
Block 2 |
Nilesh |
1011 |
2 |
89 |
Some blocks of an ordered (sequential) file of students records with Roll no. as the ordering field
Advantages of sequential file over unordered files :
- Reading of records in order of the ordering key is extremely efficient.
- Finding the next record in order of the ordering key usually, does not require additional block access. Next record may be found in the same block.
- Searching operation on ordering key is must faster. Binary search can be utilized. A binary search will require log2b block accesses where b is the total number of blocks in the file.
Disadvantages of sequential file :
- Sequential file does not give any advantage when the search operation is to be carried out on non- ordering field.
- Inserting a record is an expensive operation. Insertion of a new record requires finding of place of insertion and then all records ahead of it must be moved to create space for the record to be inserted. This could be very expensive for large files.
- Deleting a record is an expensive operation. Deletion too requires movement of records.
- Modification of field value of ordering key could be time consuming. Modifying the ordering field means the record can change its position. This requires deletion of the old record followed by insertion of the modified record.