Indexing
Question 1 |
Consider a relational table r with sufficient number of records, having attributes A1, A2,…, An and let 1≤p≤n. Two queries Q1 and Q2 are given below.
- Q1: πA1,...,Ap(σAp=c(r)) where c is a constant
Q2: πA1,...,Ap(σc1≤Ap≤c2(r)) where c1 and c2 is a constants
The database can be configured to do ordered indexing on Ap or hashing on Ap. Which of the following statements is TRUE?
Ordered indexing will always outperform hashing for both queries | |
Hashing will always outperform ordered indexing for both queries | |
Hashing will outperform ordered indexing on Q1, but not on Q2 | |
Hashing will outperform ordered indexing on Q2, but not on Q1. |
Question 1 Explanation:
Hashing works well on the "equal" queries, while ordered indexing works well better on range queries.
For example, consider B+ tree, once you have searched a key in B+; you can find range of values via the block pointers pointing to another block of values on the leaf node level.
For example, consider B+ tree, once you have searched a key in B+; you can find range of values via the block pointers pointing to another block of values on the leaf node level.
Question 2 |
A clustering index is defined on the fields which are of type
non-key and ordering | |
non-key and non-ordering | |
key and ordering
| |
key and non-ordering
|
Question 2 Explanation:
Create index files, fields could be non-key attributes and which are in ordered form so as to form clusters easily.
Question 3 |
There are 5 records in a database.
There is an index file associated with this and it contain the values 1, 3, 2, 5 and 4. Which one of the fields is the index built form?
Age | |
Name | |
Occupation | |
Category |
Question 3 Explanation:
Indexing will be on occupation field because occupation field lexigraphically sorted will give the sequence 1, 3, 2, 5, 4.
There are 3 questions to complete.
