written 6.7 years ago by |
• Information is kept in files.
• Files reside on secondary storage.
• When this information is to be used, it has to be accessed and brought into primary main memory.
• Information in files could be accessed in many ways.
• It is usually dependent on an application.
The information stored in the file needs to be accessed and read into the computer memory. There are different methods available to do it. Some of them are:
Sequential Access
Direct Access
Indexed Sequential Access
Sequential Access
A simple access method, information in a file is accessed sequentially one record after another. To process with record all the 1-1 records previous to 1 must be accessed. Sequential access is based on the tape model that is inherently a sequential access device. Sequential access is best suited where most of the records in a file are to be processed. For example: Transaction files.
It is a very common approach which is used by editors and compilers usually. The Read and Write operations form the major part of the operations done on a file. A read operation reads the next portion of the file and automatically advances the file pointer, which tracks the I/O location. A write operation appends to the end of the file and advances to the end of the newly written material.
Direct Access Sometimes it is not necessary to process every record in a file. It may not be necessary to process records in the order in which they are present. Information present in a record of a file is to be accessed only if some key value in that record is known. In all such cases, direct access is used. Direct access is based on the disk that is a direct access device and allows random access of any file block. Since a file is a collection of physical blocks, any block and hence the records in that block are accessed.
This type of access method provides a speedy access to the file. It provides immediate access to large amount of information. Here a file is made up of logical records that allow programs to read and write. It allows the programs to read and write the records in a rapid manner in no particular (or pre-defined) order.
It is based on the disk-model of a file, as a disk allows random access to any block. For direct access, we can view the file as a numbered sequence of blocks or records. This method is usually used in databases.
For example, Master files. Databases are often of this type since they allow query processing that involves immediate access to large amounts of information. All reservation systems fall into this category. Not all operating systems support direct access files. Usually files are to be defined as sequential or direct at the time of creation and accessed accordingly later.
Sequential access of a direct access file is possible but direct access of a sequential file is not.
Indexed Sequential Access:
This access method is a slight modification of the direct access method. This method is built on top of Direct access method.It is in fact a combination of both the sequential access as well as direct access.
The main concept is to access a file direct first and then sequentially from that point onwards. This access method involves maintaining an index. The index is a pointer to a block. To access a record in a file, a direct access of the index is made. The information obtained from this access is used to access the file.
For example, the direct access to a file will give the block address and within the block the record is accessed sequentially.
Sometimes indexes may be big. So hierarchies of indexes are built in which one direct access of an index leads to info to access another index directly and so on till the actual file is accessed sequentially for the particular record. The main advantage in this type of access is that both direct and sequential access of files is possible.