Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between hashing and indexing?

I have studied hashing in DBMS (extensible, linear) and about Indexing in DBMS (sparse, dense, indexes based on secondary key, etc.), but I am unable to understand what the difference is between Hashing and Indexing. Are these two techniques used together or is just either used? I am confused because the purpose of both techniques seem to be to enable us to retrieve the data quickly, so I think either should be sufficient.

Can anyone clarify the difference?

like image 791
user1543957 Avatar asked Nov 20 '12 09:11

user1543957


People also ask

What is the difference between hash based indexing and tree based indexing?

Hash-based indexing does not maintain any ordering among the indexed values; rather it is based on mapping the search-key values on a collection of buckets. Therefore it can only address equality (or membership) queries. Tree-based indices maintain order and can thus also address range queries.

Can we do indexing using hashing?

In DBMS, hashing is a technique to directly search the location of desired data on the disk without using index structure. Hashing method is used to index and retrieve items in a database as it is faster to search that specific item using the shorter hashed key instead of using its original value.

What is indexing explain about hash based indexing?

Indexing and Hashing. Data is stored in the form of records and every record has a key field, which helps it to be. recognize uniquely. Indexing is a data structure technique to efficiently retrieve records from. the database on some attributes on which the indexing has been done.


2 Answers

What is indexing?

Indexing is a way of sorting a number of records on multiple fields. Creating an index on a field in a table creates another data structure which holds the field value, and pointer to the record it relates to. This index structure is then sorted, allowing Binary Searches to be performed on it.

What is hashing?

Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string. Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value.

I think this may clear your doubt.

like image 141
Heena Hussain Avatar answered Sep 28 '22 18:09

Heena Hussain


Hash is sort of an index: it can be used to locate a record based on a key -- but it doesn't preserve any order of records. Based on hash, one can't iterate to the succeeding or preceding element. This is however, what index does (in the context of databases.)

like image 38
Aki Suihkonen Avatar answered Sep 28 '22 19:09

Aki Suihkonen