Monday, February 6, 2017

Lecture 17 - File Organization



There are several ways of organizing records in a file.

  • Serial file organization
  • Sequential file organization
  • Indexed serial file organization
  • Indexed sequential file organization
  • Random i hash i direct file organization

Serial file and Sequential file
A serial file will consist of records in a order which the records are entered. Therefore if a new record needs to be inserted it will be done to the end of a file

Example:

 

When considering sequential files storage of records is done either in ascending or descending order. Therefore when inserting a record it will first of all identify the exact location for storage.

Example:

 

After record 37 was inserted

When we need to search for a group of records which are in order the best form of file organization is a sequential file.

If records need to be updated quickly the best form of file organization is a serial file.


Indexed Serial Files
An index serial file will consist several indexed layers. This will depend on the complexity of the serial file. Zero indexed layer of this file organization is same as a sequential file.

Inserting Records

When inserting value '35' from the second indexed layer identify which indexed page has the relevant set of records. (Indexed page 'J')

From first indexed layer identify which index page has the relevant values (g). From the zero indexed layer identify where value '35' should be stored. Thereafter re-arrange the indexed layers appropriately.

Searching for Records

Searching for record '29'

From the second indexed layer identify on which page record'29' exists. (Page i)

From the first indexed layer identify on which page the record exists (Page C)

Finally from the data file read the records one by one from the relevant page until you find the necessary record.


Indexed Sequential File
The final data file in this method of file organization is a sequential file. Therefore we need not have an additional indexed layer to sequence the records. (As in index serial file organization), therefore accessing an index sequential file is faster compared with accessing an indexed serial file.

Inserting Records

When inverting records to an index sequential file we cannot attach the particular record to the end of the file as in an index serial file organization.

The exact location to store the record should be identified by following the indexed layers.

Based on the insertion the index layers may have to be updated.

As in sequential files the index sequential file provides to access a group of records which is in order comparatively faster than the serial file.


Hash / Random and Direct Files

Hash files uses hashing algorithms for example mod 3 in order to generate a bucket number to add new record. Based on generated bucket address the record will be stored in particular area. When the bucket area is full additional records will be sent to the particular overflow area.

1 comment:

  1. Thank you so much for such a detailed lecture. I was looking for a lecture on File Organization for some days now, but couldn't find it.

    ReplyDelete

Important Notice!

Dear students and friends. When you commenting please do not mention your email address. Because your email address will be publicly available and visible to all. Soon, it will start sending tons of spams because email crawlers can extract your email from feed text.

To contact me directly regarding any inquiry you may send an email to info@bcslectures.website and I will reply accordingly.