Lecture 6
Lecture 6
Facilitator : Dr.S.Saraswathi
File Organizations
File organization
• Sequential
• Random
• Linked organization
• Inverted files
Sequential File Organization
• The easiest method for file Organization is Sequential method. In this
method the file are stored one after another in a sequential manner. There
are two ways to implement this method:
• Pile File Method – This method is quite simple, in which we store the
records in a sequence i.e one after other in the order in which they are
inserted into the tables.
• Sorted File Method –In this method, As the name itself suggest
whenever a new record has to be inserted, it is always inserted in a sorted
(ascending or descending) manner.
• Sorting of records may be based on any primary key or any other key.
Pros
• Fast and efficient method for huge amount of data.
• Simple design.
• Files can be easily stored in magnetic tapes i.e cheaper storage
mechanism.
Cons
• Time wastage as we cannot jump on a particular record that is
required, but we have to move in a sequential manner which
takes our time.
• Sorted file method is inefficient as it takes time and space for
sorting records.
Random File Organization
• Records are stored at random locations on the disk.
• Numeric value of primary key is used to determine the node into which a
particular record is to be stored.
• Directory lookup: the index is not direct access type but is a dense index
maintained using a structure suitable for index operations.
• Retrieving a record involves searching the index for the record address
and then accessing the record itself.
• It requires more accesses for retrieval and update, since index searching
will generally require more than one access.
• In sequential ith record is placed at location li, then the i+1st record is placed at
li + c where c is the length of ith record or some fixed constant.
• In linked organization the next logical record is obtained by following link value
from present record.
• We can generalize this idea for secondary key level also. We just set up
indexes for each key and allow records to be in more than one list.
• Multilists records with the same key value are linked together with link
information being kept in individual record.
• Since the index entries are variable length, index maintenance becomes
complex fro multilists. Benefits being Boolean queries require only one access
per record satisfying the query. Queries of type k1=xx and k2=yy can be
handled similarly by intersecting two lists.
• The retrieval works in two steps.
• In the first step, the indexes are processed to obtain a list of records satisfying
the query and in the second, these records are retrieved using the list.
• The no. of disk accesses needed is equal to the no. of records being retrieved +
the no. to process the indexes.
• Inverted files represent one extreme of file organization in which only the index
structures are important.
• Inverted files may also result in space saving compared with other file
structures when record retrieval doesn’t require retrieval of key fields.
• In this case key fields may be deleted from the records unlike multilist
structures.
Thank you