There are different modes available for accessing files as mentioned below:
3. Indexed sequential and
Here the sequential mode has been discussed in detail.
What is a Sequential File?
– A file that stores in it the records one after the other i.e., as per the key field order is called a sequential file.
– The major benefit with the serial files is that they are stored both on the tapes and disks and the records are accessed from the beginning point of the file.
– However, the sequential files are not void of benefits.
– Firstly, with sequential files you can display the records as per the order of the key field. Even though, it makes the addition of a record slower but eventually speeds up the search schedules.
– One type of sequential file is the indexed sequential file which is used for storing the records one after the other in the sequence of the key field.
– The difference between this and the usual sequential file is that this file has an index which makes it even more useful.
– The presence of an index makes the direct access of the records possible.
Let us see what an index is?
– Index is a file derived from the main file and consisting of the below mentioned two parts:
1. Pointers: These pointers point to where the required record can be found in the file.
2. Key fields: These fields are sorted sequentially.
Indexed sequential files prove to be useful particularly in the following situations:
1. Whenever it is required to process all of the records and that too in a sequential order.
2. Whenever it is required to randomly access the individual records.
Methods for Storing Sequential Files
Our focus is up on the methods that are available for storing the sequential files. They way the sequential files are stored is quite irrelevant. The thing that matters is that is it possible to access the sequential files in a sequential manner from the program.
This is largely in contrast with the random access files to which access is gained through a record index in order to go to a particular record in the file. But in the modern software systems as well as the programming languages the difference between the two modes is actually lessening since now it has been made possible to seek any record within a sequential file and that too in a very efficient manner.
Files are actually data repositories that reside up on the backing storage such as CD – ROM, magnetic tape, hard disk etc. These days files are being used to store a number of different types of data such as spread sheets, documents, programs, sounds, videos, record based data and pictures etc. These files can be processed by COBOL but generally it used for processing the record files. Two types of record based file organization are there:
1. Serial files or the sequential files (as called by COBOL): Here, the organization and accessing of the records is done serially.
2. Direct access files:
– Here the records are organized in such a way that it becomes to directly access a particular record without looking up to the previous records.
– Sequential files are actually a straightforward way of reading and writing the files.
– Perhaps their degree of portability to the other programs is the major reason for why they are so used.
– Also, because of this the sequential files can be thought of as a common denominator of processing the data.
– Also, these files can be read over by word processors and editors, used by applications such as data base managers and can be transferred over the internet.
– The basic idea behind the success of the sequential files is to keep them simple.