An index in a DBMS is said to be dense if an index entry appears for every search-key value in the indexed file. Otherwise it is called a sparse index. Consider the following two statements.
: A hash index must be a dense index
: A tree index can be a sparse index
Which one of the following options is correct?
View worked solution
Answer: A
Note: There is a minor typographical error in the question statement where the second statement is labeled as instead of . We will treat the second statement as .
Let us analyze both statements based on database indexing principles:
Statement : A hash index must be a dense index
- A hash index uses a hash function to map a search-key value directly to a bucket address containing the record pointer(s).
- Because hashing does not preserve the physical or logical order of the keys, we cannot perform sequential scans to locate missing keys.
- To find any record using its search-key, the hash table must contain an entry for every single search-key value present in the database.
- Therefore, a hash index must be a dense index. Thus, is true.
Statement : A tree index can be a sparse index
- A sparse index contains index entries for only some of the search-key values (typically one entry per data block/page). This requires the underlying data file to be physically sorted by the search-key.
- A tree can be designed as a sparse index (e.g., a sparse clustering index or primary index). In this setup, the leaf nodes of the tree store only the search-key of the first record of each data block.
- To find a record, we traverse the tree to find the largest index key less than or equal to the target key, and then scan that specific data block sequentially.
- Therefore, a tree index can be a sparse index. Thus, is true.
Since both statements and are true, the correct option is A.
Free practice · Your answers on this page are not saved.
