The different file access methods are as highlighted below:
Sequential Access:
- This is the most common method.
- Here the information present in the file is accessed in a sequential fashion, one record after the other.
- 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:
- 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.
Indexed access:
- This method is built on top of Direct access method.
- Here an index contains the pointers to various blocks of the file.
- So, to find a record inside a file, we firstly search the index and later use the pointer obtained to access the file directly and find the record we have been searching for.
Please leave a comment below and share with other students in your network if you found this answer helpful. Happy learning!