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 -

Static Hashing in DBMS

Static hashing refers to a hashing technique that allows users to execute lookups on a dictionary set that has been finalised (all the objects present in the dictionary are final and do not change).

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

Table of Contents

What is Static Hashing in DBMS?

Whenever a search-key value is specified in static hashing, the hash algorithm always returns the same address. In case 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 number of buckets available remains constant.

The resultant data bucket address with static hashing will always be the same. That is, if we use the hash function mod (5) to obtain an address for EMP ID =103, we will always get the same bucket address 3. The bucket address will not change in this case.

As a result, the total number of data buckets present in the memory remains constant throughout the process of static hashing. In this case, the memory utilised to hold the data will include five data buckets.

Static Hashing Operations

Search a Record

When a record is needed, the very same hash function is used in order to get the address of that bucket in which the data is kept.

Insert a Record

When a new record is entered into the table, the hash key is used to construct an address for the new record, and the record is placed there.

Delete a Record

To delete a record, we must first retrieve the record that will be destroyed. The records for this address will then be deleted from memory.

Update a Record

To edit a record, we’ll use a hash function to find it first, then change the data record.

If we wish to add a new record to the file, but the address of the data bucket formed by the hash function isn’t empty, or information already exists in that address, we can’t add the record. Bucket overflow is a term used in static hashing to describe this occurrence. In this strategy, this is a critical condition.

There are a number of options for dealing with this scenario. The following are some of the most widely utilised methods:

Open Hashing

Whenever a hash function generates any address that already contains data, the next bucket is assigned to it, and this process is called Linear probing.

For instance, if R3 is a new address that needs to be entered, the hash function will generate 112 as R3’s address. However, the address that was produced is already full; as a result, the system selects 113 as the next available data bucket and assigns R3 to it.

Close Hashing

When a data bucket is filled, a new one is created for the very same hash result and connected after the old one, and this method is called Overflow chaining.

For example, if R3 is a new address that has to be added to the database, the hash function will assign it the address 110. However, this bucket is too full to accommodate the additional data. In this scenario, a new bucket is placed and linked to the end of 110 buckets.

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.

*

*