Insertion: Records has to be inserted at the place dictated by the sequence of keys. As is obvious, direct insertions into the main data file would lead to frequent rebuilding of the file. This difficulty could be mitigated by reserving' overflow areas' in the file for insertions. However, this leads to wastage of space. The common method is to employ transaction logging. This works as follows:
- It gathers records for insertion in a transaction file in their order of their arrival.
- While population of the transactions file has ceased, sort the transaction file in the order of the key of the primary data file
- Merge the two files on the basis of key to obtain a new copy of the primary sequential file.
Usually such insertions are done in a batch mode while the activity/program which populates the transaction file have ceased. The structure of the transaction files records will be identical to that of the primary file.
2. Deletion: Deletion is the reverse procedure of insertion. The space occupied by the record must be freed for use. Usually deletion (like-insertion) is not done instantly. The concerned record is written to a transaction file. During merging, the corresponding data record will be dropped from the primary data file.
3. Updation: Updation is a combination of insertion & deletions. The record with the new values is inserted and the earlier version deleted. It is also done using transaction files.
4. Retrieval: User programs will frequently retrieve data for viewing prior to making decisions. Thus, it is essential that this data reflects the latest state of the data, if the merging activity has not still taken place.
Usually, Retrieval is done for a particular value of the key field. Before return in to the user, the data record must be merged with the transaction record (if any) for that key value.
The other two operations 'creation' & 'deletion' of files are attained by simple programming language statements.