A database is a collection of interrelated records. The mechanism used to represent and store the records in a file is called the file organization. On the other hand, the arrangement of records in a file is known as file organization.
Objectives of File Organization: The main objectives of file organization are as follows:
- To provide an efficient method to locate records needed for processing.
- To facilitate file creation and it’s updating in future.
For organizing record efficiently in the form of computer file, following three things are important:
- A logical method should be observe to organized records in a file.
- File structure should be so designed that it would allow quick access to needed data items.
- Means of adding or deleting data items or records from files must be presented.
Factors to be consider in FO: In choosing a file organization for a particular file in a database, we should consider seven important factors:
- Fast data retrieval.
- High amount of work for processing data input & maintenance transaction.
- Efficient use of storage space.
- Protection from failures or data loss.
- Minimizing need for reorganization.
- Accommodating growth.
- Security from unauthorized use.
Types of File Organization: There are four types of FO. These are given below:
1. Heap (pile) FO: In this file organization the records are stored in available blank block as they arrived, i.e. record can be placed anywhere in the file where there is space for the records. There is no ordering of records. Inserting a new record into a heap file is very easy. The new record is added at the end of last block. Searching for a record in a heap file is a difficult process and takes a lot of time. A linear search of the whole file is required for locating a record.
2. Serial FO: In serial file the records are placed one after another. However, there is no specific order in the arrangement of these records. On a magnetic tape storage device, the record of a serial file are written along the length of the tape.
Serial files are usually created as temporary files and then stored in some sequence before being processed.
Advantages of Serial File Organization: The main advantage of a serial FO is that the space on the storage medium can be utilized to the maximum possible extent.
3. Sequential File Organization: A sequential file is a file in which the records are stored in some order, say the student file contains records of students in the ascending order of roll number of students sequential files are preferable when they are to be stored on sequential access devices such as magnetic tapes.
Advantages of Sequential File: The main advantages of sequential file organization are:-
- File design is simple.
- Location of records requires only the record key.
- Low-cost file media such as magnetic tapes can be used for storing data.
Limitations/Draw-backs of sequential file: The main draw-backs of sequential FO are:-
- Updating requires that all transaction records are stored in the record key sequence.
- Addition and deletion of records isn’t simple.
4. Direct Access File Organization: A sequential file isn’t suitable for online enquire suppose a customer at a bank wishes to know the balance amount is his saving account. If the customer file is organized sequentially, the record of this customer has to be obtain by searching sequentially from the beginning. There is no way of picking out the particular record without traversing the file from the beginning and this way take a long time. Hence, in such situations, random access or direct access FO provides a means of accessing records speedily.
- Immediate access to record is possible.
- Up-to-date information will always be available on the file.
- Several files can be simultaneously updated deletion.
- Addition & deletion of record is not very complex.
- Less efficient in the use of storage space.
- Uses a relatively expansive medium.
- Data security is less due to direct access facility.