database – What is the difference between hashing and indexing?

database – What is the difference between hashing and indexing?

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.

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

database – What is the difference between hashing and indexing?

  • Hashing do not guarantee that distinct values will hash to distinct address.
  • Collision is there in Hashing.
  • Hashing results in Overflow.
  • No need to access an index structure to locate data & then read data from DB File.
  • There is command to define Indexing but not for Hashing.

Leave a Reply

Your email address will not be published. Required fields are marked *