Static Hashing in DBMS

Last Updated : 5 Dec, 2025

Static hashing is a hashing technique used in DBMS where the structure of the hash table remains fixed. This means the number of buckets does not increase or decrease, and all data stored in these buckets remains in the same place throughout.

In static hashing, when you apply a hash function to a search key, it always produces the same address. For example, if you use a hash function like:

h(key) = key mod 5

and you want to store EmpId = 103, it will always map to:

103 mod 5 = 3 → Bucket 3

No matter how many times you search or insert that value, the bucket number will always be the same. This keeps the structure predictable and simple.

Because the number of buckets is constant, memory is divided into fixed partitions. Each partition (bucket) always keeps the same position and does not move or change during the entire hashing process. This is why static hashing is considered “static”—the buckets and their addresses never change, even as data is accessed repeatedly.

Data Buckets in Memory (Static Hashing)
Data Buckets in Memory (Static Hashing)

Operations in Static Hashing

1. Searching a Record

To search for data, the DBMS applies the same hash function to the key.
The function returns the bucket address where the record should be stored.
If the record is there, it is returned immediately.

Example:
h(103) = 103 mod 5 = 3 → Look in bucket 3.

2. Inserting a Record

When a new record is added, the hash function calculates the bucket address where it should be placed.
If the target bucket is empty, the record is inserted.
If the bucket is full, a bucket overflow occurs.

3. Deleting a Record

To delete a record, the hash function is used to locate the exact bucket.
Once the correct bucket is found, the record is removed from that location.

4. Updating a Record

For updating, the DBMS again uses the hash function to find the target bucket.
Once the record is located, its information can be modified.

However, if an update operation requires adding new data and the bucket for that key is already full, the system cannot place the new data in the same bucket—this leads to bucket overflow.

Handling Bucket Overflow

In static hashing, bucket overflow happens when the bucket where data should go is already full.
Two common ways to handle this are:

1. Open Hashing (Linear Probing)

If the original bucket is full, the system searches for the next empty bucket and stores the record there.

Example:
Hash result → bucket 112 is full → place data in bucket 113.

2. Closed Hashing (Overflow Chaining)

If the bucket is full, a new overflow bucket is created and linked to the original bucket.
This forms a chain of buckets for the same hash value.

Example:
Bucket 112 is full → a new bucket is added and connected to bucket 112.

Advantages of Static Hashing

The advantages of using static hashes in a DBMS are:

  • Performance is very good for small data sets.
  • Help with storage management.
  • Hash keys facilitate access to address information.
  • The primary key value can be used by the hash value.

Disadvantages of Static Hashing

Disadvantages of using static hashing techniques in DBMS are:

  • Static hashing is not a good choice for big data.
  • This process takes longer than usual because the hash function has to go through all memory locations in the DBMS system.
  • Does not work with extensible databases.
  • The sorting technique is not good compared to other hashing techniques.
Comment
Article Tags:

Explore