Sequential access: Information from the file is processed in order i.e. one record after another. It is commonly used access mode. For example, editors and compilers access files in sequence. A read operation read information from the file in a sequence i.e. read next reads the next portion of the file and automatically advances a file pointer. A write operation writes information into the file in a sequence i.e. write next appends to the end of the file and advances to the end of the newly written material. Such a file can be reset to the beginning. In some operating systems, a program may be able to skip forward or backward n records for some integer n.
As shown in above diagram, a file can be rewind (moved in backward direction) from the current position to start with beginning of the file or it can be read or write in forward direction.
Direct access: It is also called as relative access. A file is made up of fixed length logical records that allow programs to read and write records rapidly in no particular order. Direct access method is based on disk model of a file which allows random access to any file block. For direct access a file is viewed as a numbered sequence of blocks or records. So we can directly read block 14, then block 53 and so on. This method is used for immediate access to large amount of information. Database can be accessed with direct access method. For example, when a query concerning a particular subject arrives, we compute which block contains the answer and then read that block directly to provide the desired information. Read n operation is used to read the nth block from the file whereas write n is used to write in that block. The block numbers provided by the user to the operating system is a relative block number. A relative block number is an index relative to the beginning of the file. The first relative block of file is 0; the next is 1 and so on. Actual absolute disk address of the block is different from the relative address. The use of relative block numbers allow the operating system to decide where the file should be placed and helps t prevent the user from accessing portions of the file system that may not be part of his file.