Professional Documents
Culture Documents
• Cost estimation
• Basic Concepts
• Ordered Indices
• B+ - Tree Index Files
• B - Tree Index Files
• Static Hashing
• Dynamic Hashing
• Comparison of Ordered Indexing and Hashing
• Index Definition in SQL
• Multiple-Key Access
Data
Index Block 0
Block 0
M
Data
Block 1
M
Index
Block 1
M
M
CIS552 Indexing and Hashing 10
Index Update: Deletion
• If deleted record was the only record in the file with its
particular search-key value, the search-key is deleted from
the index also.
• Single-level index deletion:
» Dense indices – deletion of search-key is similar to file record
deletion.
» Sparse indices – if an entry for the search key exists in the index, it
is deleted by replacing the entry in the index with the next search-
key value in the file (in search-key order). If the next search-key
value already has an index entry, the entry is deleted instead of
being replaced.
350
Brighton A-217 750
400
Downtown A-101 500
500
Downtown A-110 600
600
Miami A-215 700
700
Perryridge A-102 400
750
Perryridge A-201 900
900
Perryridge A-218 700
Redwood A-222 700
Round Hill A-305 350
Brighton Downtown
leaf node
Brighton A-212 750
Downtown A-101 500
Downtown A-110 600
account file
P1 K1 P2 … Pn-1 Kn-1 Pn
Perryridge
Miami Redwood
Perryridge
Perryridge
Miami Redwood
Perryridge
Perryridge
Miami Redwood
Miami
Downtown Redwood
bucket 0 bucket 5
Perryridge A-102 400
Perryridge A-201 900
Perryridge A-218 700
Miami A-215 700
bucket 1 bucket 6
bucket 2 bucket 7
bucket 3 bucket 8
Brighton A-217 750 Downtown A-101 500
Round Hill A-305 350 Downtown A-110 600
bucket 4 bucket 9
Redwood A-222 700
bucket 1
A-215 Brighton A-217 750
A-305 Downtown A-101 500
bucket 2 Downtown A-110 600
A-101
A-110
Miaimi A-215 700
Perryridge A-102 400
bucket 3
A-217 A-201 Perryridge A-201 900
A-102 Perryridge A-218 700
bucket 4 Redwood A-222 700
A-218 Round Hill A-305 350
bucket 5
bucket 6
A-222
i1
bucket 1
i
hash suffix
..00
..01 i2
bucket 2
..10
..11
i3
bucket 3
bucket address table
branch-name h(branch-name)
Brighton 0110 1101 1111 1011 0010 1100 0011 0000
Downtown 0010 0011 1010 0000 1100 0110 1001 0001
Miami 1110 0111 1110 1101 1011 1111 0011 0011
Perryridge 1011 0001 0010 0100 1001 0011 0110 1111
Redwood 0011 0101 1010 0110 1100 1001 1110 1110
Round Hill 1111 1000 0011 1111 1001 1100 0000 1101
0
0 bucket 1
1
Brighton A-217 750
hash suffix 2
..00
..01
2
..10
Downtown A-101 500
..11 Downtown A-110 600
2
Redwood A-222 700
3
Redwood A-722 750
..000
..001 3 3
..010 Downtown A-101 500 Downtown A-611 820
..011 Downtown A-110 600
..100
..101 3
Round Hill A-432 500
..110
..111
3
bucket address table Miami A-102 400
Perryridge A-201 900
Issues to consider:
• Cost of periodic re-organization
• Relative frequency of insertions and deletions
• Is it desirable to optimize average access time at the
expense of worst-case access time?
• Expected type of queries:
» Hashing is generally better at retrieving records having
a specified value of the key.
» If range queries are common, ordered indices are to be
preferred