File organization is a way of organizing the data or records in a file. It does not refer to how files are organized in folders, but how the contents of a file are added and accessed. There are several types of file organization, the most common of them are sequential, relative and indexed. They differ in how easily records can be accessed and the complexity in which records can be organized.
In a sequential file organization, records are organized in the sequence by which they were added. You cannot insert a new record between existing records, but only at the end of the last record. It is a simple file organization that allows you to process batches of records in the file without adding or deleting anything. However, to access a particular record, processing must run through all the other records above it because it does not generate any random key to identify the location of the record. Searching for a record, especially when there are thousands of entries, may be time consuming. Also, inserting or deleting records would mean rearranging the entire sequence.
Another type of organizing files would be relative to the location where the file begins. A relative key is assigned to determine the order of files. The first record would have a relative number of 1, the second record would have a relative number of 2 and so on. It is also called relative, because the sizes of each record may vary, unlike in a sequential organization where the record sizes must be fixed to arrange sequentially. Records may be 128-bytes or 256-bytes in size and they can be arranged relative to each other, with any of the free bytes between them marked as unused. This makes it possible to insert records in those unused areas. Also, with the relative key, you can randomly access any record without starting from the top record. The disadvantage is its dependence on relative keys. If you do not know the relative key of a particular record, you won't be able to randomly access the file.
Video of the Day
An indexed file organization contains reference numbers, like employee numbers, that identify a record in relation to other records. These references are called the primary keys that are unique to a particular record. Alternate keys can also be defined to allow alternate methods of accessing the record. For example, instead of accessing an employee's record using employee numbers, you can use an alternate key that reference employees by departments. This allows greater flexibility for users to randomly search through thousands of records in a file. However, it employs complex programming in order to be implemented.