Saturday, August 8, 2009

Direct files

A direct file, also called a random or relative file consists of records organized in such a way that it is possible for the computer to directly locate the key of the desired record without having to search through a sequence of other records. This means that the time required for online enquiry and updating of a few records is much faster than when batch techniques are used. However a direct access storage device, DASD such as a drum, disk, strip file, or mass core is essential for storing a direct file. A record is stored in a direct file by its key field. Although it might be possible to directly use the storage location numbers in DASD as the keys for the records stored in those locations, this is seldom done. Instead, an arithmetic procedure called hashing is frequently used. In this method, an address generating function is used to convert the record key number into DASD storage address. The address generating function is selected in such a manner that the generated address should be distributed uniformly over the entire range of the file area and a unique address should be generated for each record key. However in practice, the above constraints are usually not satisfied and the address generating function often maps a large number of records to the same storage address. Several methods are followed to overcome this problem of collision when it occurs. One approach is to include a pointer field at the location calculated by the hashing function. This field points to the DASD location of another record that has the same calculated address value. When the computer is given the key of a record to be processed at a later date, it reuses the hashing function to locate the stored record. If the record is found at the location calculated by the hashing function, the search is over and the record is directly accessed for processing. On the other hand, if the record at the calculated address does not have the correct key, the computer looks at the pointer field to continue the search. Advantages of direct fields
  1. The access to, and retrieval of a record is quick and direct. Any record can be located and retrieved directly in a fraction of a second without the need for a sequential search of the file
  2. Transactions need not be stored and placed in sequence prior to processing
  3. Accumulation of transactions into batches is not required before processing them. They may be processed as and when generated
  4. It can also provide up-to-the-minute information in response to inquiries from simultaneously usable online stations
  5. If required, it is also possible to process direct file records sequentially in a record key sequence
  6. A direct file organization is most suitable for interactive online applications such as airline or railway reservation systems, teller facility in banking applications, etc.

Disadvantages of direct files

  1. These files must be stored on a direct-access storage device. Hence, relatively expensive hardware and software resources are required
  2. File updation (addition and deletion of records) is more difficult as compared to sequential files
  3. Address generation overhead is involved for accessing each record due to hashing function
  4. May be less efficient in the use of storage space than sequentially organized fields
  5. Special security measures are necessary for online files that are accessible from several stations

No comments:

Post a Comment

Search Techno Talk

Google Groups
Subscribe to Techno Talk
Email:
Visit this group