The file is a collection of records related to each other. The file size is limited by the size of the memory and storage medium.
There are two important features of the file:
1. File Activity
2. File Volatility
File activity: It specifies that percent of actual records proceed in a single run. If a small percent of the record is accessed at any given time, the file should be organized on disk for direct access in contrast. If a fare percentage of records affected regularly then storing the file on the tape would be more efficient & less costly.
File volatility: It addresses the properties of record changes. File records with many changes are highly volatile means the disk design will be more efficient than tape.
File organization ensures that records are available for processing. It is used to determine an efficient file organization for each base relation.
For example, if we want to retrieve employee records in alphabetical order of name. Sorting the file by employee name is a good file organization. However, if we want to retrieve all employees whose marks are in a certain range, a file is ordered by employee name would not be a good file organization.
Types of File Organization
There are three types of organizing the file:
- Sequential file organization
- Direct file organization
- Indexed sequential file organization
- Inverted list organization
1. Sequential file organization
- Storing and sorting in a contiguous block within files on tape or disk is called a sequential file organization.
- In a sequential access file organization, all records are stored in sequential order. The records are arranged in the ascending or descending order of a key field.
- Sequential file search starts from the beginning of the file and the records can be added at the end of the file.
- In a sequential file, it is not possible to add a record in the middle of the file without rewriting the file.
Advantages of sequential file
- It is simple to program and easy to design.
- A sequential file is the best to use storage space.
Disadvantages of sequential file
- A sequential file is a time-consuming process.
- It has high data redundancy.
- Random searching is not possible.
2. Direct file organization
- Direct access file is also known as random access or relative file organization.
- In direct access file, all records are stored in direct access storage devices (DASD), such as a hard disk. The records are randomly placed throughout the file.
- The records do not need to be in sequence because they are updated directly and rewritten back in the same location.
- This file organization is useful for immediate access to large amounts of information. It is used in accessing large databases.
- It is also called as hashing.
Advantages of direct file organization
- Direct access file helps in the online transaction processing system (OLTP) like an online railway reservation system.
- In direct access file, sorting of the records is not required.
- It accesses the desired records immediately.
- It updates several files quickly.
- It has better control over record allocation.
Disadvantages of direct file organization
- The direct access file does not provide a backup facility.
- It is expensive.
- It has less storage space as compared to a sequential file.