File Organization: Basic Concepts of Files

A file is a collection of related sequence of records. A collection of field names and their corresponding data types constitutes a record. A data type, associated with each field, specifies the types of values a field can take. All records in a file are of the same record type.

1. Records and Record Types

Data is generally stored in the form of records. A record is a collection of fields or data items and data items is formed of one or more bytes. Each record has a unique identifier called record-id. The records in  a file are one of  the following two types:

  1. Fixed length
  2. Variable length

1.1. Fixed Length Records

Every record in the file has exactly the same size (in bytes). The record slots are uni- form and are arranged in a continuous manner in the file. A record is identified using both record-id and slot number of the record. The Figure 3.1 shows a structure of fixed length STUDENT record and the Figure 3.2 shows a portion of a file of fixed length records.

Advantage of Fixed Length Records : The following are the advantages of fixed length records.

  1. Insertion and deletion of records in the file are simple to implement since the space made available by a deleted record is same as needed to insert a  new

Disadvantage of Fixed Length Records : The major disadvantages of fixed length records are as  follows:

  1. In fixed length records, since the length of record is fixed, it causes wastage of memory space. For example, if the length is set up to 50 characters and most of the records are less than 25 characters, it causes wastage of precious memory
  2. It is an inflexible For example, if it is required to increase the length of a record, then major changes in  program and database  are needed.

1.2. Variable Length Records

Every record in the file need not be of the same size (in bytes). Therefore, the records in the file have different sizes. The major problem with variable length record is that when a new record is to be inserted, an empty slot of the exact length is required. If the slot is smaller, it cannot be used and if it is too big, the extra space is just wasted. There are two methods to store variable length records with a fixed length representation. These are Reserved space and pointers. A file may have variable length records due to following reasons:

  1. One or more than one fields of a record are of varying size but the records in the file are of  same record type.
  1. One or more than one fields may have multiple values for individual records and are called repeating fields but the records in the file are of same record type.
  2. One or more than one fields are optional e., they may have values for some but not for all records. The file records in this case are also of the same record type.
  3. The file contains records of different record types and different sizes.

Advantage of Variable Length Records : The advantages of variable length records are as follows:

  1. It reduces manual mistakes as database automatically adjust the size of
  2. It saves lot of memory space  in case  of records of  variable
  3. It is a flexible approach since future enhancements are very easy to

Disadvantage of Variable Length Records : The disadvantages of variable length records are as  follows:

  1. It increases the overhead of DBMS because database have to keep record of the sizes of all records.

2. Types of Files

The following three types of files are used in database systems:

  1. Master file
  2. Transaction file
  3. Report

 

  1. Master file: This file contains information of permanent nature about the The master file act as a source of reference data for processing transactions. They accumulate the information based on the transaction data.
  2. Transaction file: This file contains records that describe the activities carried out by the This file is created as a result of processing transactions and preparing transaction documents. These are also used to update the master file permanently.
  3. Report file: This file is created by extracting data from the different records to prepare a report  e.g. A report file  about the  weekly sales  of  a particular  item.

Source: Gupta Satinder Bal, Mittal Aditya (2017), Introduction to Database Management System, 2nd Edition-University Science Press (2017)

Leave a Reply

Your email address will not be published. Required fields are marked *