Ways to organize files

Table of Contents

File organization is a way of organizing data or records in a file. It does not refer to how files are organized into folders, but how the content of a file is added and accessed. There are several types of file organization, the most common are sequential, relative and indexed. These differ in the ease of accessing the records and in the complexity with which the records can be organized.

Sequential

In a sequential file organization, records are organized according to the sequence in which they were added. You cannot insert a new record between existing records, it must be placed after the last record. It is a simple type of organization that allows you to process many records in the file without having to add or delete anything. However, to access a specific record, the processing must go through all the other records first because there is no key to identify the location of the file. Searching for a file, especially when there are thousands of entries, can be very cumbersome. Also, inserting or deleting records could mean having to reorder the entire sequence.

Relative

Another type of file organization would be relative to the location of the file. A relative key is assigned to determine the order of the files. The first record should have a number relative to 1, the second record a number relative to 2, and so on. It is also called relative because the sizes of each record can vary, unlike a sequential organization where the sizes of the records must be set to order them sequentially. Records can be 128 bytes or 256 bytes long and can be ordered relative to each other, with any free bytes between them marked “unused”. This makes it possible to insert records into unused areas. Also, with the relative key, you can randomly access any record without starting from the first one. The downside is its reliance on relative keys. If you don’t know the relative key for a specific record, you won’t be able to access the file.

Indexed

An organization indexed from a file contains reference numbers, such as employee numbers, that identify one record from others. These references are known as the primary keys that are unique to a particular record. Alternate keys can also be defined as methods of accessing a record. For example, instead of accessing an employee’s record using the employee’s numbers, you can use the alternate password that sorts employees by department. This allows users more flexibility to randomly search thousands of records within a file. However, its implementation involves complex programming.