Lecture 3.3.3 Sequential, Relative
Lecture 3.3.3 Sequential, Relative
ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE
AND ENGG.
2
Sequential File Organization
• This method is the easiest method for file organization. In this method, files are
stored sequentially. This method can be implemented in two ways:
• 1. Pile File Method:
• It is a quite simple method. In this method, we store the record in a sequence,
i.e., one after another. Here, the record will be inserted in the order in which
they are inserted into tables.
• In case of updating or deleting of any record, the record will be searched in the
memory blocks. When it is found, then it will be marked for deleting, and the
new record is inserted.
3
• Insertion of the new record:
• Suppose we have four records R1, R3 and so on upto R9 and R8 in a
sequence. Hence, records are nothing but a row in the table.
Suppose we want to insert a new record R2 in the sequence, then it
will be placed at the end of the file. Here, records are nothing but a
row in any table.
4
Sorted File Method:
• In this method, the new record is always inserted at the file's end,
and then it will sort the sequence in ascending or descending order.
Sorting of records is based on any primary key or any other key.
• In the case of modification of any record, it will update the record
and then sort the file, and lastly, the updated record is placed in the
right place.
5
• Insertion of the new record:
• Suppose there is a preexisting sorted sequence of four records R1,
R3 and so on upto R6 and R7. Suppose a new record R2 has to be
inserted in the sequence, then it will be inserted at the end of the
file, and then it will sort the sequence.
6
Pros of sequential file organization
• It contains a fast and efficient method for the huge amount of data.
• In this method, files can be easily stored in cheaper storage
mechanism like magnetic tapes.
• It is simple in design. It requires no much effort to store the data.
• This method is used when most of the records have to be accessed
like grade calculation of a student, generating the salary slip, etc.
• This method is used for report generation or statistical calculations.
7
Cons of sequential file organization
8
Direct (Random) File Organization
• Records are read directly from or written on to the file.
• The records are stored at known address.
• Address is calculated by applying a mathematical function to the key
field.
Direct (Random) File Organization
• A random file would have to be stored on a direct access backing
storage medium e.g. magnetic disc, CD, DVD
14
Disadvantages of direct access file
organization
• Direct access file does not provide back up facility.
• It is expensive.
• It has less storage space as compared to sequential file.
15
THANK YOU
16