Fixed Length Record File Organization:
Those records which has fixed size like let us consider a file ' account records ' for our bank database.
type deposit=record(here deposit is the table name)
account_name:char(10);
Branch_name:char(22);
Balance:real;
end
account_name:char(10);,Branch_name:char(22);,Balance:real; they are three are attributes of table deposit.
Let assume 1 char = 1 byte 1 real= 8 bytes so our one records becomes Account_ name char 10*1=10 bytes Branch_ name char 22*1 =22 bytes Balance: real 8*1 =08 bytes ------------------------------------- 40 bytes ----------------------------------------
Then we can follow an approach.
• Use of first 40 bytes for the first record
• The next 40 bytes for the second record.
But there are two problems with this simple approach.
• 1) Deleting the record from this will create an empty block which may occur waste of memory space. So to overcome this problem we must fill this block with records of the file, or we must have way of marking deleted records so that it can be ignored.
• 2) If block size is less than 40 bytes
So we have to store records in 2 or more block according the block size. But for this kind of problem write and read operations become tedious.
New Approach: At the beginning of the file, a certain number of bytes as a "File Header".This file header contains a variety of information about the file with the address of the records whose contents are deleted.
We use this first record to store the address of the second available record and so on.
• We can assume these stored addresses as pointers as they point location of a record.
• The deleted record thus form a linked list or a "free list".
• On insertion of a new record, we use record pointer to by the header. And we change the "header pointer" to point to next available record.
• If no space is available, we add new record to the "end of the file".