Recall & Review
beginner
What is a hash index in a database?
A hash index is a type of database index that uses a hash function to map search keys to specific locations, allowing fast data retrieval based on exact matches.
Click to reveal answer
beginner
How does a hash function help in hash indexing?
A hash function converts a search key into a fixed-size value (hash code) that points to the location where the data is stored, enabling quick access without scanning the entire dataset.
Click to reveal answer
beginner
What type of queries are hash indexes best suited for?
Hash indexes are best for queries that look for exact matches, such as finding a record with a specific key value, but they are not efficient for range queries.
Click to reveal answer
intermediate
What is a limitation of hash indexes compared to B-tree indexes?
Hash indexes do not support range queries or ordered traversal of data, while B-tree indexes allow both exact match and range queries efficiently.
Click to reveal answer
intermediate
What happens if two keys produce the same hash value in a hash index?
This is called a collision. Hash indexes handle collisions using methods like chaining (linking entries) or open addressing (finding another slot), ensuring data can still be retrieved correctly.
Click to reveal answer
What is the main advantage of using a hash index?
✗ Incorrect
Hash indexes provide very fast lookups for exact key matches but do not support range queries or ordered traversal.
Which of the following is a common problem in hash indexes?
✗ Incorrect
Collisions occur when two keys hash to the same location; hash indexes use special methods to handle collisions.
Hash indexes are NOT suitable for which type of query?
✗ Incorrect
Hash indexes do not support range queries efficiently because they do not maintain order.
Which data structure is commonly used as an alternative to hash indexes for range queries?
✗ Incorrect
B-tree indexes maintain sorted order and support efficient range queries.
What does a hash function do in a hash index?
✗ Incorrect
A hash function converts keys into hash codes that point to where data is stored for quick access.
Explain how a hash index works and when it is most useful.
Think about how a key is transformed and used to find data quickly.
You got /4 concepts.
Compare hash indexes with B-tree indexes in terms of query types they support.
Consider what kinds of searches each index type handles best.
You got /4 concepts.