SlideShare a Scribd company logo
1 of 36
B.Bhuvaneswaran
Assistant Professor (SG)
Department of CSE
Database Technology
Hashing
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 2
Introduction
 Hash file organization method is the one where data is stored at
the data blocks whose address is generated by using hash
function.
 The memory location where these records are stored is called as
data block or bucket. This bucket is capable of storing one or more
records.
 The hash function can use any of the column value to generate the
address. Most of the time, hash function uses primary key to
generate the hash index - address of the data block.
 Hash function can be simple mathematical function to any
complex mathematical function.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 3
Example
 Following Fig. represents the records of student can be searched
using hash based indexing.
 In this example the hash function is based on the age field of the
record. Here the index is made up of data entry k* which is actual
data record.
 For a hash function the age is converted to binary number format
and the last two digits are considered to locate the student record.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 4
Hash Based Indexing
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 5
Hash Table
 Hash table is a data structure used for storing and retrieving data
quickly.
 Every entry in the hash table is made using Hash function.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 6
Hash Function
 Hash function is a function used to place data in hash table.
 Similarly hash function is used to retrieve data from hash table.
 Thus the use of hash function is to implement hash table.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 7
Example
 Consider hash function as key mod 5. The hash table of size 5.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 8
Collision
 Collision is situation in which hash function returns the same
address for more than one record.
 For example:
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 9
Probe
 Each calculation of an address and test for success is known as a
probe.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 10
Synonym
 The set of keys that has to the same location are called synonyms.
 In above given hash table computation 25 and 55 are synonyms.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 11
Overflow
 When hash table becomes full and new record needs to be
inserted then it is called overflow.
 For example:
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 12
Static Hashing
 In this method of hashing, the resultant data bucket address will
be always same.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 13
Static Hashing
 That means, if we want to generate address for Stud_RollNo =
34789. Here if we use mod 10 hash function, it always result in the
same bucket address 9. There will not be any changes to the
bucket address here.
 Hence number of data buckets in the memory for this static
hashing remains constant throughout. In our example, we will
have ten data buckets in the memory used to store the data.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 14
Static Hashing
 For example, if we want to add the Stud_RollNo = 35111 in above
hash table then as there is no space for this entry and the hash
address indicate to place this record at index 1, we create
overflow chain as shown in Table.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 15
Example
 If we want to add the Stud_RollNo = 35111 in above hash table
then as there is no space for this entry and the hash address
indicate to place this record at index 1, we create overflow chain
as shown in Table.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 16
Advantages of Static Hashing
 (1) It is simple to implement.
 (2) It allows speedy data storage.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 17
Disadvantages of Static Hashing
 1) In static hashing, there are fixed number of buckets. This will
create a problematic situation if the number of records grow or
shrink.
 2) The ordered access on hash key makes it inefficient.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 18
Open Hashing
 The open hashing is a form of static hashing technique.
 When the collision occurs, that means if the hash key returns the
same address which is already allocated by some data record,
then the next available data block is used to enter new record
instead of overwriting the old record.
 This technique is also called as linear probing.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 19
Example
 Consider insertion of record 105 in the hash table below with the
hash function h (key) mod 10.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 20
Example
 The 105 is probed at next empty data block as follows:
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 21
Advantages
 1) It is faster technique.
 2) It is simple to implement.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 22
Advantages
 1) It forms clustering, as the record is just inserted to next free
available slot.
 2) If the hash table gets full then the next subsequent records
cannot be accommodated.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 23
Dynamic Hashing
 The problem with static hashing is that it does not expand or
shrink dynamically as the size of the database grows or shrinks.
 Dynamic hashing provides a mechanism in which data buckets are
added and removed dynamically and on-demand.
 The most commonly used technique of dynamic hashing is
extendible hashing.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 24
Extendible Hashing
 The extendible hashing is a dynamic hashing technique in which, if
the bucket is overflow, then the number of buckets are doubled
and data entries in buckets are re-distributed.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 25
Example
 In extendible hashing technique the directory of pointers to
bucket is used.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 26
Example
 To locate a data entry, we apply a hash function to search the data
we us last two digits of binary representation of number.
 For instance, binary representation of 32* = 10000000.
 The last two bits are 00. Hence we store 32* accordingly.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 27
Insertion Operation
 Suppose we want to insert 20* (binary 10100). But with 00, the
bucket A is full. So we must split the bucket by allocating new
bucket and redistributing the contents, across the old bucket and
its split image.
 For splitting, we consider last three bits of h(r).
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 28
Insertion Operation
 The redistribution while insertion of 20* is as shown in following
Fig.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 29
Insertion Operation
 The split image of bucket A i.e. A2 and old bucket A are based on
last two bits i.e. 00. Here we need two data pages, to adjacent
additional data record. Therefore, here it is necessary to double
the directory using three bits instead of two bits.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 30
Insertion Operation
 There will be binary versions for buckets A and A2 as 000 and 100.
 In extendible hashing, last bits d is called global depth for
directory and d is called local depth for data pages or buckets.
After insertion of 20*, the global depth becomes 3 as we consider
last three bits and local depth of A and A2 buckets become 3 as
we are considering last three bits for placing the data records.
Refer Fig.
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 31
Insertion Operation
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 32
Insertion Operation
 Suppose if we want to insert 11*, it belongs to bucket B, which is
already full. Hence let us split bucket B into old bucket B and split
image of B as B2.
 The local depth of B and B2 now becomes 3.
 Now for bucket B, we get and 1 = 001
 11 = 10001
 For bucket B2, we get
 5 = 101
 29 = 11101
 and 21 =10101
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 33
Insertion Operation
Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 34
Static vs Dynamic Hashing
Static Hashing Dynamic Hashing
The number of buckets are fixed. The number of buckets are not fixed.
Chaining is used. There is no need of chaining.
Open hashing and closed hashing are forms of
static hashing.
Extendible hashing and linear hashing are forms
of dynamic hashing.
Space overhead is more. Minimum space overhead due to dynamic
nature.
As file grows the performance of static hash
function decreases.
There is no degradation in performance when
the file grows.
The bucket address table is not required. The bucket address table is required.
The bucket is directly accessed. The bucket address table is used to access the
bucket.
Queries
Thank You

More Related Content

What's hot

Presentation on 8086 Microprocessor
Presentation  on   8086 MicroprocessorPresentation  on   8086 Microprocessor
Presentation on 8086 MicroprocessorNahian Ahmed
 
Memory organization
Memory organizationMemory organization
Memory organizationishapadhy
 
Huffman's algorithm in Data Structure
 Huffman's algorithm in Data Structure Huffman's algorithm in Data Structure
Huffman's algorithm in Data StructureVrushali Dhanokar
 
Control Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitControl Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitabdosaidgkv
 
Instruction Execution Cycle
Instruction Execution CycleInstruction Execution Cycle
Instruction Execution Cycleutsav_shah
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack LavanyaJ28
 
Hash table in data structure and algorithm
Hash table in data structure and algorithmHash table in data structure and algorithm
Hash table in data structure and algorithmAamir Sohail
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulationSanjeev Patel
 
EE5440 – Computer Architecture - Lecture 1
EE5440 – Computer Architecture - Lecture 1EE5440 – Computer Architecture - Lecture 1
EE5440 – Computer Architecture - Lecture 1Dilawar Khan
 
Open addressiing &rehashing,extendiblevhashing
Open addressiing &rehashing,extendiblevhashingOpen addressiing &rehashing,extendiblevhashing
Open addressiing &rehashing,extendiblevhashingSangeethaSasi1
 
Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Student
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms HashingManishPrajapati78
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting AlgorithmsPranay Neema
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)Sandesh Jonchhe
 
Memory organization in computer architecture
Memory organization in computer architectureMemory organization in computer architecture
Memory organization in computer architectureFaisal Hussain
 
Hashing and separate chain
Hashing and separate chainHashing and separate chain
Hashing and separate chainVijayapriyaPandi
 
Von-Neumann machine and IAS architecture
Von-Neumann machine and  IAS architectureVon-Neumann machine and  IAS architecture
Von-Neumann machine and IAS architectureShishir Aryal
 

What's hot (20)

Presentation on 8086 Microprocessor
Presentation  on   8086 MicroprocessorPresentation  on   8086 Microprocessor
Presentation on 8086 Microprocessor
 
Memory organization
Memory organizationMemory organization
Memory organization
 
Huffman's algorithm in Data Structure
 Huffman's algorithm in Data Structure Huffman's algorithm in Data Structure
Huffman's algorithm in Data Structure
 
Control Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitControl Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unit
 
Instruction Execution Cycle
Instruction Execution CycleInstruction Execution Cycle
Instruction Execution Cycle
 
Hashing PPT
Hashing PPTHashing PPT
Hashing PPT
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
 
Hash table in data structure and algorithm
Hash table in data structure and algorithmHash table in data structure and algorithm
Hash table in data structure and algorithm
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
Lecture 3 instruction set
Lecture 3  instruction setLecture 3  instruction set
Lecture 3 instruction set
 
Cpu organisation
Cpu organisationCpu organisation
Cpu organisation
 
EE5440 – Computer Architecture - Lecture 1
EE5440 – Computer Architecture - Lecture 1EE5440 – Computer Architecture - Lecture 1
EE5440 – Computer Architecture - Lecture 1
 
Open addressiing &rehashing,extendiblevhashing
Open addressiing &rehashing,extendiblevhashingOpen addressiing &rehashing,extendiblevhashing
Open addressiing &rehashing,extendiblevhashing
 
Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
 
Memory organization in computer architecture
Memory organization in computer architectureMemory organization in computer architecture
Memory organization in computer architecture
 
Hashing and separate chain
Hashing and separate chainHashing and separate chain
Hashing and separate chain
 
Von-Neumann machine and IAS architecture
Von-Neumann machine and  IAS architectureVon-Neumann machine and  IAS architecture
Von-Neumann machine and IAS architecture
 

Similar to DT-08-Hashing.PPTX

Hashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfHashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfJaithoonBibi
 
A Novel Approach of Caching Direct Mapping using Cubic Approach
A Novel Approach of Caching Direct Mapping using Cubic ApproachA Novel Approach of Caching Direct Mapping using Cubic Approach
A Novel Approach of Caching Direct Mapping using Cubic ApproachKartik Asati
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageZurich_R_User_Group
 
Lecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).pptLecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).pptMuhammadTalhaAwan1
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)IJERD Editor
 
databasehomeworkhelp.com_ Database System Assignment Help (1).pptx
databasehomeworkhelp.com_ Database System Assignment Help (1).pptxdatabasehomeworkhelp.com_ Database System Assignment Help (1).pptx
databasehomeworkhelp.com_ Database System Assignment Help (1).pptxDatabase Homework Help
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica"FENG "GEORGE"" YU
 
Performance Analysis of Hashing Mathods on the Employment of App
Performance Analysis of Hashing Mathods on the Employment of App Performance Analysis of Hashing Mathods on the Employment of App
Performance Analysis of Hashing Mathods on the Employment of App IJECEIAES
 
Design and Implementation of Multiplier Using Kcm and Vedic Mathematics by Us...
Design and Implementation of Multiplier Using Kcm and Vedic Mathematics by Us...Design and Implementation of Multiplier Using Kcm and Vedic Mathematics by Us...
Design and Implementation of Multiplier Using Kcm and Vedic Mathematics by Us...IJMER
 
COSA and CSA based 32 -bit unsigned multipler
COSA and CSA based 32 -bit unsigned multiplerCOSA and CSA based 32 -bit unsigned multipler
COSA and CSA based 32 -bit unsigned multiplerinventy
 
FPGA Based Implementation of AES Encryption and Decryption with Low Power Mul...
FPGA Based Implementation of AES Encryption and Decryption with Low Power Mul...FPGA Based Implementation of AES Encryption and Decryption with Low Power Mul...
FPGA Based Implementation of AES Encryption and Decryption with Low Power Mul...IOSRJECE
 
Intro to Data warehousing lecture 11
Intro to Data warehousing   lecture 11Intro to Data warehousing   lecture 11
Intro to Data warehousing lecture 11AnwarrChaudary
 
Intro to Data warehousing lecture 14
Intro to Data warehousing   lecture 14Intro to Data warehousing   lecture 14
Intro to Data warehousing lecture 14AnwarrChaudary
 
Intro to Data warehousing lecture 19
Intro to Data warehousing   lecture 19Intro to Data warehousing   lecture 19
Intro to Data warehousing lecture 19AnwarrChaudary
 

Similar to DT-08-Hashing.PPTX (20)

Hashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfHashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdf
 
A Novel Approach of Caching Direct Mapping using Cubic Approach
A Novel Approach of Caching Direct Mapping using Cubic ApproachA Novel Approach of Caching Direct Mapping using Cubic Approach
A Novel Approach of Caching Direct Mapping using Cubic Approach
 
Lec1
Lec1Lec1
Lec1
 
FractalTreeIndex
FractalTreeIndexFractalTreeIndex
FractalTreeIndex
 
01_intro-cpp.ppt
01_intro-cpp.ppt01_intro-cpp.ppt
01_intro-cpp.ppt
 
01_intro-cpp.ppt
01_intro-cpp.ppt01_intro-cpp.ppt
01_intro-cpp.ppt
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
 
Lecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).pptLecture#1(Algorithmic Notations).ppt
Lecture#1(Algorithmic Notations).ppt
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 
databasehomeworkhelp.com_ Database System Assignment Help (1).pptx
databasehomeworkhelp.com_ Database System Assignment Help (1).pptxdatabasehomeworkhelp.com_ Database System Assignment Help (1).pptx
databasehomeworkhelp.com_ Database System Assignment Help (1).pptx
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
 
Performance Analysis of Hashing Mathods on the Employment of App
Performance Analysis of Hashing Mathods on the Employment of App Performance Analysis of Hashing Mathods on the Employment of App
Performance Analysis of Hashing Mathods on the Employment of App
 
Design and Implementation of Multiplier Using Kcm and Vedic Mathematics by Us...
Design and Implementation of Multiplier Using Kcm and Vedic Mathematics by Us...Design and Implementation of Multiplier Using Kcm and Vedic Mathematics by Us...
Design and Implementation of Multiplier Using Kcm and Vedic Mathematics by Us...
 
COSA and CSA based 32 -bit unsigned multipler
COSA and CSA based 32 -bit unsigned multiplerCOSA and CSA based 32 -bit unsigned multipler
COSA and CSA based 32 -bit unsigned multipler
 
FPGA Based Implementation of AES Encryption and Decryption with Low Power Mul...
FPGA Based Implementation of AES Encryption and Decryption with Low Power Mul...FPGA Based Implementation of AES Encryption and Decryption with Low Power Mul...
FPGA Based Implementation of AES Encryption and Decryption with Low Power Mul...
 
Intro to Data warehousing lecture 11
Intro to Data warehousing   lecture 11Intro to Data warehousing   lecture 11
Intro to Data warehousing lecture 11
 
Intro to Data warehousing lecture 14
Intro to Data warehousing   lecture 14Intro to Data warehousing   lecture 14
Intro to Data warehousing lecture 14
 
Intro to Data warehousing lecture 19
Intro to Data warehousing   lecture 19Intro to Data warehousing   lecture 19
Intro to Data warehousing lecture 19
 
Lecture1a data types
Lecture1a data typesLecture1a data types
Lecture1a data types
 
Python - Lecture 12
Python - Lecture 12Python - Lecture 12
Python - Lecture 12
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 

Recently uploaded (20)

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 

DT-08-Hashing.PPTX

  • 1. B.Bhuvaneswaran Assistant Professor (SG) Department of CSE Database Technology Hashing
  • 2. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 2 Introduction  Hash file organization method is the one where data is stored at the data blocks whose address is generated by using hash function.  The memory location where these records are stored is called as data block or bucket. This bucket is capable of storing one or more records.  The hash function can use any of the column value to generate the address. Most of the time, hash function uses primary key to generate the hash index - address of the data block.  Hash function can be simple mathematical function to any complex mathematical function.
  • 3. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 3 Example  Following Fig. represents the records of student can be searched using hash based indexing.  In this example the hash function is based on the age field of the record. Here the index is made up of data entry k* which is actual data record.  For a hash function the age is converted to binary number format and the last two digits are considered to locate the student record.
  • 4. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 4 Hash Based Indexing
  • 5. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 5 Hash Table  Hash table is a data structure used for storing and retrieving data quickly.  Every entry in the hash table is made using Hash function.
  • 6. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 6 Hash Function  Hash function is a function used to place data in hash table.  Similarly hash function is used to retrieve data from hash table.  Thus the use of hash function is to implement hash table.
  • 7. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 7 Example  Consider hash function as key mod 5. The hash table of size 5.
  • 8. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 8 Collision  Collision is situation in which hash function returns the same address for more than one record.  For example:
  • 9. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 9 Probe  Each calculation of an address and test for success is known as a probe.
  • 10. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 10 Synonym  The set of keys that has to the same location are called synonyms.  In above given hash table computation 25 and 55 are synonyms.
  • 11. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 11 Overflow  When hash table becomes full and new record needs to be inserted then it is called overflow.  For example:
  • 12. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 12 Static Hashing  In this method of hashing, the resultant data bucket address will be always same.
  • 13. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 13 Static Hashing  That means, if we want to generate address for Stud_RollNo = 34789. Here if we use mod 10 hash function, it always result in the same bucket address 9. There will not be any changes to the bucket address here.  Hence number of data buckets in the memory for this static hashing remains constant throughout. In our example, we will have ten data buckets in the memory used to store the data.
  • 14. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 14 Static Hashing  For example, if we want to add the Stud_RollNo = 35111 in above hash table then as there is no space for this entry and the hash address indicate to place this record at index 1, we create overflow chain as shown in Table.
  • 15. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 15 Example  If we want to add the Stud_RollNo = 35111 in above hash table then as there is no space for this entry and the hash address indicate to place this record at index 1, we create overflow chain as shown in Table.
  • 16. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 16 Advantages of Static Hashing  (1) It is simple to implement.  (2) It allows speedy data storage.
  • 17. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 17 Disadvantages of Static Hashing  1) In static hashing, there are fixed number of buckets. This will create a problematic situation if the number of records grow or shrink.  2) The ordered access on hash key makes it inefficient.
  • 18. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 18 Open Hashing  The open hashing is a form of static hashing technique.  When the collision occurs, that means if the hash key returns the same address which is already allocated by some data record, then the next available data block is used to enter new record instead of overwriting the old record.  This technique is also called as linear probing.
  • 19. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 19 Example  Consider insertion of record 105 in the hash table below with the hash function h (key) mod 10.
  • 20. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 20 Example  The 105 is probed at next empty data block as follows:
  • 21. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 21 Advantages  1) It is faster technique.  2) It is simple to implement.
  • 22. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 22 Advantages  1) It forms clustering, as the record is just inserted to next free available slot.  2) If the hash table gets full then the next subsequent records cannot be accommodated.
  • 23. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 23 Dynamic Hashing  The problem with static hashing is that it does not expand or shrink dynamically as the size of the database grows or shrinks.  Dynamic hashing provides a mechanism in which data buckets are added and removed dynamically and on-demand.  The most commonly used technique of dynamic hashing is extendible hashing.
  • 24. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 24 Extendible Hashing  The extendible hashing is a dynamic hashing technique in which, if the bucket is overflow, then the number of buckets are doubled and data entries in buckets are re-distributed.
  • 25. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 25 Example  In extendible hashing technique the directory of pointers to bucket is used.
  • 26. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 26 Example  To locate a data entry, we apply a hash function to search the data we us last two digits of binary representation of number.  For instance, binary representation of 32* = 10000000.  The last two bits are 00. Hence we store 32* accordingly.
  • 27. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 27 Insertion Operation  Suppose we want to insert 20* (binary 10100). But with 00, the bucket A is full. So we must split the bucket by allocating new bucket and redistributing the contents, across the old bucket and its split image.  For splitting, we consider last three bits of h(r).
  • 28. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 28 Insertion Operation  The redistribution while insertion of 20* is as shown in following Fig.
  • 29. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 29 Insertion Operation  The split image of bucket A i.e. A2 and old bucket A are based on last two bits i.e. 00. Here we need two data pages, to adjacent additional data record. Therefore, here it is necessary to double the directory using three bits instead of two bits.
  • 30. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 30 Insertion Operation  There will be binary versions for buckets A and A2 as 000 and 100.  In extendible hashing, last bits d is called global depth for directory and d is called local depth for data pages or buckets. After insertion of 20*, the global depth becomes 3 as we consider last three bits and local depth of A and A2 buckets become 3 as we are considering last three bits for placing the data records. Refer Fig.
  • 31. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 31 Insertion Operation
  • 32. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 32 Insertion Operation  Suppose if we want to insert 11*, it belongs to bucket B, which is already full. Hence let us split bucket B into old bucket B and split image of B as B2.  The local depth of B and B2 now becomes 3.  Now for bucket B, we get and 1 = 001  11 = 10001  For bucket B2, we get  5 = 101  29 = 11101  and 21 =10101
  • 33. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 33 Insertion Operation
  • 34. Dept. of Computer Science and Business Systems Rajalakshmi Engineering College 34 Static vs Dynamic Hashing Static Hashing Dynamic Hashing The number of buckets are fixed. The number of buckets are not fixed. Chaining is used. There is no need of chaining. Open hashing and closed hashing are forms of static hashing. Extendible hashing and linear hashing are forms of dynamic hashing. Space overhead is more. Minimum space overhead due to dynamic nature. As file grows the performance of static hash function decreases. There is no degradation in performance when the file grows. The bucket address table is not required. The bucket address table is required. The bucket is directly accessed. The bucket address table is used to access the bucket.