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 -

Dynamic Hashing in DBMS

Dynamic hashing is a mechanism for dynamically adding and removing data buckets on demand. The hash function aids in the creation of a huge number of values in this hashing.

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

Table of Contents

What is Dynamic Hashing in DBMS?

The dynamic hashing approach is used to solve problems like bucket overflow that can occur with static hashing. As the number of records increases or decreases, data buckets grow or shrink in this manner. This method makes hashing dynamic, allowing for insertion and deletion without causing performance issues. The extendible hashing method is another name for this technology.

Searching a Key

  • Calculate the key’s hash address first.
  • Determine the number of bits used in the directory; these bits are referred to as i.
  • Take the hash address’s least significant i bits. This returns the directory’s index.
  • Now, using the index, navigate to the directory and look for the bucket address in which the record may be located.

Inserting a New Record

  • To begin, repeat the retrieval technique, ending up in a bucket somewhere.
  • Place the record in the bucket if there is still room in it.
  • In case the bucket is completely filled, split it and disperse the records.

Example

Consider the following classification of keys into buckets based on their hash address prefix:

Since the last two bits in 2 and 4 are 00, they will be placed in bucket B0. Because the last two bits of the numbers 5 and 6 are 01, they will be placed in bucket B1. Since the last two parts of 1 and 3 add up to 10, they will be placed in bucket B2, and as the last two bits in 7 are 11, they will be placed in B3.

Inserting a key 9 into the above structure with hash address 10001:

  • Key 9 must be put into the first bucket because its hash address is 10001. However, because bucket B1 is full, it will be split.
  • Because the final three bits of 5, 9 are 001, they will be split into bucket B1, whereas the last three bits in 6 are 101, and they will be split into bucket B5.
  • The 2nd and 4th keys are still in B0. Because the last two bits of both entries are 00, the record in B0 is pointed to 000 and 100 entries.
  • The first and third keys are still in B2. Because the last two bits of both entries are 10, the record in B2 is pointed to 010 and 110 entries.
  • The keys 7 and 8 are still in B3. Because the last two bits of both entries are 11, the record in B3 is pointed to 111 and 011 entries.

Dynamic Hashing Pros

  • The performance of this method does not degrade as the amount of data in the system grows. To accommodate the data, it massively increases the memory size.
  • Memory is properly utilised in this manner since it shrinks and grows with the information. There will be no unused memory to be found.
  • This strategy is ideal for a dynamic database with data that increases and shrinks on a regular basis.

Dynamic Hashing Cons

  • In this strategy, as the data amount grows, the bucket size grows as well. The bucket address table will keep track of these data addresses due to the fact that the data address will change as the buckets expand and shrink. Maintenance of the bucket address table gets difficult when there is a significant increase in data.
  • The bucket overflow problem will also occur in this case. However, reaching this state may take less time than static 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.

*

*