File Organization Of Variable Length Records:

Lets take an example for variable length records

type account_list = record

branch_name:char(22);

account-info:array[1....infinity] of record;

account-number:char(10);

balance:real;

end

end

In this we define account_info as an array with an arbitrary number of elements.

The type definition does not limit the number of elements in the array.

There is no limit on how large a record can be(up to of course the size of the disk storage!)

Byte - String Representation: Approaches

1) -end-of-record - symbol: Our first approach to implement variable length record is to attach a special end-of-Record-symbol to the end of each record. So by this we can then store each record as a string of consecutive bytes.

2) storing the record length at the beginning of each record, instead of use of end-of-records-symbol.

Disadvantages of these approaches:

•1) It is not easy to reuse space occupied by deleted record. Small space of disk is wasted in order to insert / delete operations.

Byte string representation

•2) no space for records to grow longer, if a variable-length record becomes longer, it must be moved.

- movement is costly if pointers to the record are stored elsewhere in the database.

Variable Length Records: "Slotted Page Structure":

A modified form of byte string representation, called the ' slotted page structure' used for organizing records within a single block.

Slotted page structure has a header at the beginning of each block, containing the following information :

a) number of records entries

• b) end of free space in the block

• c) location and size of each record

Slotted Page

• Records can be moved around within a page to keep them contiguous with no empty space between them; entry in the header must be updated.

• Pointers should not point directly to records - instead they should point to the entry for the records in header.

****There is an another approach to implement variable length record efficiently in a file system

By using one or more fixed length records

We have two Approaches of doing this

1) Reserved Space: We can fixed a length of block to the know maximum length (it should not be exceeded) of the variable length record.

Reserved space approach

unused spaces of shorter record filled with a "null or end-of-records symbol".

2) List Representation:

• A variable length record is represented by a list of fixed length record, chained together via pointers.

•It can be used even if the maximum record length is not known.

List representation

So overcome to disadvantage, allowing blocks in file.

2 blocks are Anchor Blocks and Overflow Block:

Anchor Block: Which contains the first set of Record of a chain.

Overflow block: Which contains records other than those that are the first record of a chain.

Anchor overflow_block


Facebook Likes

Youtube