The main difference between static and dynamic hashing is that, in static hashing, the resultant data bucket address is always the same while, in dynamic hashing, the data buckets grow or shrink according to the increase and decrease of records.
It is not possible to search all the indexes to find the data in a large database. Hashing provides an alternative to this issue. Furthermore, it allows calculating the direct location of data on the disk without using indexes. Hashing uses mathematical functions called hash functions to generate addresses of data records. In addition, the memory locations that store data are called data buckets. There are two types of hashing called static and dynamic hashing.
Key Areas Covered
1. What is Static Hashing
– Definition, Functionality
2. What is Dynamic Hashing
– Definition, Functionality
3. What is the Difference Between Static and Dynamic Hashing
– Comparison of Key Differences
Key Terms
Hashing, Static Hashing, Dynamic Hashing
What is Static Hashing
In static hashing, the resultant data bucket address is always the same. In other words, the bucket address does not change. Thus, in this method, the number of data buckets in memory remains constant throughout.
Operations of static hashing are as follows.
Insertion – When entering a record using static hashing, the hash function (h) calculates the bucket address for search key (k), where the record will be stored. Bucket address = h(K).
Search – When obtaining a record, the same hash function helps to obtain the address of the bucket where the data is stored.
Delete – After fetching the record, it is possible to delete the records for that address in memory.
Update – After searching the record using a hash function, it is possible to update that record.
Furthermore, one major issue in static hashing is bucket overflowing. Some methods to overcome this issue are as follows.
Overflow chaining – New bucket created for the same hash result when the buckets are full
Linear Probing – Next free bucket allocated for data when a hash function generates an address where data is already stored.
What is Dynamic Hashing
An issue in static hashing is bucket overflow. Dynamic hashing helps to overcome this issue. It is also called Extendable hashing method. In this method, the data buckets increase and decrease depending on the number of records. It allows performing operations such as insertion, deletion etc. without affecting the performance.
Operations of dynamic hashing are as follows.
Insertion – Computes the address of the bucket. If the bucket is already full, it is possible to add more buckets. Moreover, it is possible to add additional bits to the hash value and re-compute the hash function. If the buckets are not full, it is possible to add data to the bucket.
Querying – Checks the depth value of the hash index and use those bits to compute the bucket address.
Update – Performs a query and update the data.
Delete – Performs a query to locate the desired data to delete.
Difference Between Static Hashing and Dynamic Hashing
Definition
Static hashing is a hashing technique that allows users to perform lookups on a finalized dictionary set (all objects in the dictionary are final and not changing). In contrast, dynamic hashing is a hashing technique in which the data buckets are added and removed dynamically and on demand. Thus, this is the main difference between static and dynamic hashing.
Functionality
In static hashing, the resultant data bucket address is always the same. In dynamic hashing, however, the data buckets change depending on the records. Hence, this is another major difference between static and dynamic hashing.
Efficiency
Efficiency is the other difference between static and dynamic hashing. Dynamic hashing is more efficient than static hashing.
Conclusion
In brief, hashing is the method of using mathematical functions called hash functions to calculate direct locations of data records on the disk. Moreover, static and dynamic hashing are two types of hashing. The main difference between static and dynamic hashing is that, in static hashing, the resultant data bucket address is always the same while in dynamic hashing, the data buckets grow or shrink according to the increase and decrease of records.
Reference:
1. “DBMS Static Hashing – Javatpoint.” Www.javatpoint.com, Available here.
2. “DBMS Dynamic Hashing – Javatpoint.” Www.javatpoint.com, Available here.
Image Courtesy:
1. “Extendible hashing 1” Аутор: Svick – Сопствено дело (CC BY 3.0) via Commons Wikimedia
Leave a Reply