5. File Organization Methods
Post date: 26-Jun-2014 06:03:03
File Organization Methods
File organization refers to the way data is stored in a file. File organization is very important because it determines the method of access, efficiency, flexibility and storage devices to be used. There are four methods of organizing files on a storage media namely: Sequential, random, serial and indexed- sequential
- A sequentially organized file consists of records arranged in the sequence in which they are written to the file (the first record written is the first record in the file, the second record written is the second record in the file, and so on). As a result, records can be added only at the end of the file. Attempting to add records at some place other than the end of the file will result in the file begin truncated at the end of the record just written.
- Sequential files are usually read sequentially, starting with the first record in the file. Sequential files with a fixed-length record type that are stored on disk can also be accessed by relative record number (direct access).
- Records in sequential files can be read or written only sequentially.
- After you have placed a record into a sequential file, you cannot shorten, lengthen, or delete the record. However, you can update (REWRITE) a record if the length does not change. New records are added at the end of the file.
- If the order in which you keep records in a file is not important, sequential organization is a good choice whether there are many records or only a few. Sequential output is also useful for printing reports.
- Sorting makes it easier to access records
- Sorting does not remove the need to access other records as the search looks for a particular record
- Sequential records cannot support modern technologies that require fast access to stored records
- The requirement that all records be of the same size is sometimes difficult to enforce
- In random file organisation, records are stored in random order within the file. Though there is no sequencing to the placement of the records, there is however, a pre-defined relationship between the key of the record and its location within the file. In other words, the value of the record key is mapped by an established function to the address within the file where it resides. Therefore, any record within the file can be directly accessed through the mapping function in roughly the same amount of time. The location of the record within the file therefore is not a factor in the access time of the record. As such, random files are also known in some literature as direct access files.
- This method is normally used by optical disks like compact disks
- Quick retrieval of records
- The records can be of different sizes
- Serial file organization is the simplest file organization method. In serial files, records are entered in the order of their creation. As such, the file is unordered, and is at best in chronological order. Serial files are primarily used as transaction files in which the transactions are recorded in the order that they occur.
- This type of access is normally used by magnetic tapes
- It is simple
- It is cumbersome to access because you have to access all preceding records before retrieving the one being searched
- Wastage of space on medium in form of inter- record gap
- It cannot support modern high speed requirements for quick records access
- indexed file contains records ordered by a record key. Each record contains a field that contains the record key. The record key uniquely identifies the record and determines the sequence in which it is accessed with respect to other records. A record key for a record might be, for example, an employee number or an invoice number.
- An indexed file can also use alternate indexes, that is, record keys that let you access the file using a different logical arrangement of the records. For example, you could access the file through employee department rather than through employee number.