Sequential processing is suitable for applications in which the proportion of records processed in an updating run is high. However, sequential files provide slow response times and cannot adequately handle file inquiries. On the other hand, direct-access processing is inappropriate for applications like payroll, where most records are processed during a single run. When a single file must be used for both batch processing and online processing, neither direct-access nor sequential file organization is appropriate. The same customer file that is used in a weekly batch run for preparing bills by the accounting department may be used daily by order entry personnel to record orders and check credit status. To some extent, the limitations of both types of file design can be minimized by using another approach to file organization, indexed-sequential design.
In this structure, the records are stored sequentially on a direct-access storage device according to a primary key. A primary key is a field that will be unique for each record on the file. In addition, secondary keys can also be established. Secondary keys are fields that are used to gain access to records on the file but may not be unique. For instance, if zip code is chosen as a secondary key, there may be several records with the same value. Records on an indexed-sequential file can be accessed randomly by using either the primary or one of the secondary keys, or the file can be read sequentially, in order according to primary key.
The method used to gain access to a record on an indexed-sequential file is a little different from the method used for a direct-access file. Every record on an indexed-sequential file may not have its own unique address. Rather, several records may be grouped together and one address given for the entire group. An index table is created for all fields that are primary or secondary keys. The index table lists the value of the key (such as social security number) and the corresponding address on the direct-access storage device at which the group containing that record can be found. (The index table can either be stored at the beginning of the file or a separate file of indexes may be created.) A key given by the user is matched against the index table to get an approximate address for the required record. The computer then goes to that location on the direct-access storage device and checks records sequentially until the desired record is found. In the case of secondary keys, all records with that key may be retrieved.
The Figure below shows the employee file from the previous section set up as an indexed-sequential file.
Indexed-Sequential Design
The primary key is the social security number, while zip code is a
secondary key. Notice how the records are in sequence according to the social security
number on the file. To locate an employee with a zip code of 43403, the computer goes to
the index table for zip code (see Figure below).
Index Tables of Primary and Secondary Keys
Next to the value 43403 is the address on the direct-access storage
device at which the group containing the record can be found, 1015. The computer goes to
that address and reads each record in the group until the one with zip code 43403 is
found. In this case, it is the first record in the group.
Thus, an indexed-sequential file provides direct-access capability. Since
all the records are ordered according to a primary key, it also allows efficient
sequential processing.
MAKING INQUIRIES TO INDEXED-SEQUENTIAL FILES.
The file could be read sequentially for a billing operation. In addition, it could be accessed one record at a time for order-entry transactions.
ASSESSMENT OF INDEXED-SEQUENTIAL FILE DESIGN
Indexed-sequential files have a built-in flexibility that is not available with either sequential or direct-access designs. They work well in an environment where transactions are batch processed and inquiries require the fast response of direct-access processing.
Advantages of indexed-sequential design include the following:
Disadvantages of indexed-sequential design include the following:
Last Updated Jan.6/99