Methods of Sequential File Organization
The following methods are used to implement sequential file organization
- Pile File method
- Sorted File method
Pile File Method
In this method, data blocks are stored successively. Data are entered in the order in which they are placed in the table. Once found, it is marked for deletion, and new information is added in its place. To insert a new record in the file, one should add a new record at the end of the file. Suppose we have four files in order, R1, R3…. R9 and R8. If we want to add a new R2 file to the array, we must put it at the end of the file.
Insertion of new record in Pile File Method: Whenever new record is added to the file organization, it is added to the end of the existing information. Let R1, R3,…, R9, and R8 be the records stored in the file. A new record R5 file has arrived. Then this file will be added to the end of the file, that is, after the R8 file.
Sorted File Method
In this method, new files are always added to the end of the file and the order is then sorted. A primary key is used to sort the records. If a record is modified, it will first update the record, then sort the file, and then store the record in the correct location. Assume there is a pre-existing sorted array of four files: R1, R3…R9 and R8. If new data R2 needs to be added to the array, add it to the end of the data and then sort the array.
Insertion of new record in Sorted File Method: When a new file arrives, it will first be added to the end of the file, just like the heap file, and then its position in the queue will change. Let R1, R3,…, R6, and R7 be the records in the file, sorted by key. For example, the new R2 file has arrived. Then the data will first be added to the end of the data i.e. after R7 and then its position will be changed to the next of R1.
Sequential File Organization in Database
Sequential file organization is the simplest type of file organization, where files are stored one after the other, rather than storing different files in rows and columns (in a tabular form), storing data in rows. In this article, we will learn about sequential file organization and its advantages and disadvantages in databases. We will understand various methods of sequential file organization.