Indexing structures for files Flashcards
What is the importance of indexing
Indexes, or access structures, are used to speed up access to desired data. – E.g., author catalog in library
Define a search key
attribute or set of attributes used to look up records in a file.
Define and illustrate an index file
The index file is a table of <key, block_pointer> pairs.
* These are called the index entries and recap the ordering key of the first record of their pointed-to block.
*See page 5 for illustration
Index files are typically much smaller than the original file
How are indexes stored
They’re stored on disk just like the main data file, and provide other access paths that can be quicker for certain operations on certain fields.
The index file usually occupies considerably less disk blocks than the data file because its entries are much smaller
How are indexes created
Any field (or combination of fields) can be used to create an index, but there will be different index types depending on whether the field is a key
(unique), and whether the main file is sorted by it or not.
* There can be multiple indexes on one file.
Give one advantage and disadvantage of indexes
Indexes speed up access on the indexed field, but slow down updates— almost every update on the main table must also update every index.
Describe dense and sparse indexes
- A dense index has an index entry for every search key value (and hence every record) in the data file.
- A sparse (or nondense) index, on the other hand, has index entries for only some of the search values
Illustrate dense indexing
Index records contain search key value and a pointer to the actual record on the disk.
*See page 8 for illustration
What is an advantage and disadvantage of dense indexing
There is an index record for every search key value
in the database.
* This makes searching faster but requires more space to store index records itself
Illustrate sparse indexing
It is an index record that appears for only some of the values in the file.
*See page 9
What are the Types of Single-Level Ordered Indexes
Primary Indexes
Clustering Index
Secondary Index
What is an anchor record
The first record of each block
How is a record retrieved using primary indexes
To retrieve a record given its ordering key value using the index, the system does a binary search in the index file to find the index entry whose key value is ≤ the goal key’s value, then retrieves the pointed-to block from the original file
What is a primary index
An index on the ordering key (often primary key) of a sorted file.
Do the example on page 12-14