Lecture12

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: Indexing and File Structures Tyne Liang CS Dept., NCTU All rights reserved. 1 Unordered Files Also called a heap or a pile file. New records are inserted at the end of the file. A linear search through the file records is necessary to search for a record. This requires reading and searching half the file blocks on the average, and is hence quite expensive. Record insertion is quite efficient. Reading the records in order of a particular field requires sorting the file 2 Ordered Files Also called a sequential file. File records are kept sorted by the values of an ordering field. Insertion is expensive: records must be inserted in the correct order. It is common to keep a separate unordered overflow (or transaction) file for new records to improve insertion efficiency; this is periodically merged with the main ordered file. A binary search can be used to search for a record on its ordering field value. This requires reading and searching log2 of the file blocks on the average, an improvement over linear search. Reading the records in order of the ordering field is quite efficient. 3 FIGURE 13.7 Some blocks of an ordered (sequential) file of EMPLOYEE records with NAME as the ordering key field. 4 Average Access Times 5 Use Primary Index Create an index file on key attribute in advance Index file is an storage overhead and is sorted file on key attributes Data file may be unsorted/sorted Accesses: O(log2n/b.f. +1) n: number of index reco...
View Full Document

This note was uploaded on 10/25/2009 for the course EE 2011 taught by Professor Denny during the Spring '09 term at National Tsing Hua University, China.

Ask a homework question - tutors are online