Files are used to store data. The information present in the file can be accessed by various methods.
The way of retrieving data from a file is known as Access Method
The various Access Methods are as follows:
§ Sequential Access Method
§ Direct Access Method
§ Indexed Access Method
Sequential Access Method:
§ It is the simplest and most commonly used access method.
§ In Sequential Access, records are accessed in some sequence i.e. the information in the file is processed in order, one record after the other.
§ The various records are read sequentially one after the other in an order, starting at the beginning to the end of the file.
§ The various records cannot be read randomly out of order that 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.
§ Sequential File can be reset to the starting of the file.
§ Sequential access is convenient when the storage medium is magnetic tape rather than a disk.
Direct Access Method:
§ In Direct Access Method, it is possible to access the records of a file in any order.
§ For Example: if we are reading block 13, then we can read block 44 and then can read block 29.
§ 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.
§ The records can be accessed by key, rather than by position.
§ This method is used in systems implementing disks rather than magnetic tapes.
§ This method is important for many applications, for example: database systems.
§ In banking application, a customer may want to look up his current balance.
§ This can be done by account number of customer as a key. Rather than sequential reading the records for thousands of customers.
Indexed Access Method:
§ 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 book.
§ If we want to find a record of a file, first the index is searched and then the pointer from index is used to access that file.
§ In this way, A Required Record is found.
§ Index is searched sequentially and its pointer is used to access the file directly