Disadvantages of direct files direct files typically

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: d in the file. To enable this, direct file organization uses an address generating function to convert a record key value into a storage address on the disk on which the file is stored. Each record in the file is stored at the location to which the address generating function maps the record's key field value. The process is known as hashing and the address generating function is called a hashing algorithm. Although the hashing algorithm is selected in such a manner so as to generate a unique address for each record key value, but in practice, the hashing algorithm sometimes maps the key values of two or more records to the same storage address. This problem is known as collision. When a collision occurs, it may be taken care of in many ways. One method is to use a pointer at the address calculated by the hashing algorithm. This pointer points to a linked list of addresses, which contains the physical addresses of all records whose key values map to the address calculated by the hashing function. To search a record given its key value, the computer applies the hashing algorithm on the given key to generate its corresponding address. If the record is found at the calculated address, the search is over. Otherwise, the computer traverses the linked list pointed to by the pointer stored at the calculated address, accesses the addresses stored in the linked list and the corresponding records one-by-one, and compares the given key with the key of the accessed record. The search process finishes as soon as the record with the matching key is found. If required, the records of a direct file may also be processed sequentially in ascending or descending sequence of key field value. However, if a large number of records need to be processed sequentially (that is, if the activity ratio is high), direct files prove to be very inefficient as compared to sequential files because the computer has to use the hashing algorithm and reposition the read/write head of the disk for every record...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online