Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Hashing in DBMS

Hashing is a DBMS technique for searching for needed data on the disc without utilising an index structure. The hashing method is basically used to index items and retrieve them in a DB since searching for a specific item using a shorter hashed key rather than the original value is faster.

In this article, we will dive deeper into Hashing in DBMS according to the GATE Syllabus for (Computer Science Engineering) CSE. Keep reading ahead to learn more.

Table of Contents

What is Hashing in DBMS?

It can be nearly hard to search all index values through all levels of a large database structure and then get to the target data block to obtain the needed data. Hashing is a method for calculating the direct position of an information record on the disk without the use of an index structure.

To generate the actual address of a data record, hash functions containing search keys as parameters are used.

Properties of Hashing in DBMS

Data is kept in data blocks whose addresses are produced using the hashing function in this technique. Data buckets or data blocks are the memory locations where these records are stored.

In this case, a hash function can produce the address from any column value. The primary key is frequently used by the hash function to generate the data block’s address. To every complex mathematical function, a hash function is a basic mathematical function. The primary key can also be considered as the data block’s address, i.e. each row with the same address as a primary key contained in the data block.

Hashing-in-DBMS

The data block addresses are the same as the primary key value in the picture above. This hash function could alternatively be a simple mathematical function, such as exponential, mod, cos, sin, and so on. Assume we’re using the mod (5) hash function to find the data block’s address. In this scenario, the primary keys are hashed with the mod (5) function, yielding 3, 3, 1, 4, and 2, respectively, and records are saved at those data block locations.

Hashing-in-DBMS-1

Hash Organization

Bucket – A bucket is a type of storage container. Data is stored in bucket format in a hash file. Typically, a bucket stores one entire disc block, which can then store one or more records.

Hash Function – A hash function, abbreviated as h, refers to a mapping function that connects all of the search-keys K to that address in which the actual records are stored. From the search keys to the bucket addresses, it’s a function.

Types of Hashing

Hashing is of the following types:

Hashing-in-DBMS-2

Static Hashing

Whenever a search-key value is given in static hashing, the hash algorithm always returns the same address. If the mod-4 hash function is employed, for example, only 5 values will be generated. For this function, the output address must always be the same. At all times, the total number of buckets available remains constant. Click here to learn more about static hashing.

Dynamic Hashing

The disadvantage of static hashing is that it doesn’t expand or contract dynamically as the database size grows or diminishes. Dynamic hashing is a technology that allows data buckets to be created and withdrawn on the fly. Extended hashing is another name for dynamic hashing.

In dynamic hashing, the hash function is designed to output a huge number of values, but only a few are used at first. Click here to learn more on dynamic hashing.

Keep learning and stay tuned to get the latest updates on the GATE Exam along with Eligibility Criteria, GATE Syllabus for CSE (Computer Science Engineering), GATE CSE Notes, GATE CSE Question Paper, and more.

Also Explore,

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*