File Management – Access Methods

By | November 20, 2021

Access Methods in File Management

Files are used to store data. The information present in the file can be accessed by various methods. Thus, the way of retrieving data from a file is known as access method. Different systems use different access methods. The various access methods used are:

  1. Sequential access
  2. Direct access
  3. Indexed access

Sequential access

It is the simplest and most commonly used access method. In sequential access, information in the file is accessed in the order it is stored in the file i.e. one record after the other. Thus, the various records are read sequentially one after the other in an order, starting a the beginning to the end of the file. The various records cannot be read randomly out of order i.e. we cannot skip any record in between.

For example, reading of 34th record followed by 5th record and then 1st record is not possible in sequential access.

In this way, the file pointer is automatically advanced in the read operation which tracks the I/O location. record In case of write operation, the new content is appended to the end of file. Sequential file can be reset to the starting of the file. In some system, it is also possible to shift n records of some integer value backward or forward. Sequential access is convenient when the storage medium is magnetic tape, rather than disk.

Advantages of Sequential Access Method

  1. It is one of the simplest method of file access and easy to implement.
  2. There is no need for any storage space identification.
  3. It uses disk and memory efficiently.
  4. It also allows data to be stored on many types of media, in a device independent manner.
  5. Errors in the files remain localized.
  6. It is also economical and easier to organize and maintain.

Disadvantages of Sequential access method

  1. Searching a record is a time consuming affair as it allows only sequential access. To search a record at nth location entire file needs to be processed.
  2. New records can only be added to the end of a file.
  3. It requires the transactions to be sorted in a particular sequence before processing.
  4. There is high data redundancy.
  5. It is not possible to handle the random enquiries.

Direct Access

In direct access method it is possible to access the records of a file in any order (i.e. out of order). For example, if we are reading block 13, we can read block 46 after this and then block 20.

The various records can be read or write randomly. There is no restriction on the order of reading or writing for a direct access file. ta this way the records can be accessed by key, rather than by position. This method is also known as relative access method and is typically used in systems implementing disks rather than magnetic tapes. In direct access method, the various records or blocks of a file are numbered for reference purpose. In order to perform read or write operation, we specify block number where read or write operation is to be performed.

Thus, an instruction read n will read block number n. Thus a user provides a block number to an operating system. This number is known as relative block number. It is an index to starting of the file. So, in a file, the first relative block number is 0, the next relative block number is 1 and so on.

Direct access method is important for many applications, for example, database systems. In a banking application, a customer may want to look up his current balance. This can be done by locating this customer’s record using his account number as a key, rather than sequentially reading the records for thousand of the customers before this customer’s record is located and read.

Advantages of direct or random access method

  1. It results in faster access of desired record. As a result retrieval process is not so time consuming as in direct access.
  2. It does not require records to be sorted before processing.
  3. It allows faster updating of several files.
  4. It also allows the random record deletion and insertion.
  5. It is best suited for online transaction processing system like online reservation system.

Access Methods in File Management

Disadvantages of direct or random access method

  1. This method requires backup facility as records are directly updated.
  2. It requires expensive direct access storage devices such as hard disk to store records.
  3. If is less efficient as compared to sequential file organization in terms of usage of storage space.
  4. Data may be accidentally erased or overwritten unless special precautions are taken.
  5. It is not possible to access such a file sequentially.
  6. Only one key is used.

Indexed Access

In this method, an index is created for the file. This index contains pointer for various blocks of a file, just like an index in the back of a book. If we want to find a record of a file, first the index is searched and then the pointer f index is used to access that file. In this way, a required record is found. When the size of a file is large, its index itself becomes too large. In such a further an index is created for the index file. The primary index or main index contains the pointers to secondary index files, which would point to the actual data items. T another index is created for situation index.

Advantage of indexed access method

  1. This method allows records to be processed both sequentially and randomly in a efficient manner.
  2. Accessing of records is faster and less time consuming but requires index table to be properly organized.

Disadvantage of indexed access method

  1. It requires a lot of storage space because of the presence of index.
  2. As compared to other access method, indexed access is less efficient in terms of usage of storage space
  3. The indexed files have to be reorganized from time to time to get rid of deleted records and improve performance that gets gradually decreased with addition of new records.
  4. It is also expensive as it requires special software and extra storage for index.

Leave a Reply

Your email address will not be published. Required fields are marked *