Indexing
Why Indexing & Hashing?
Indexing
�
Search key value
Pointer to record
Index entry/index record
Ordered indices
[an index whose search key is different from the sequential order of the file ]
Usually dense
Types of ordered indices
Dense indices
Sparse indices
To locate a record with search-key value K we:
Index update: record insertion
Index update: record deletion
Sparse v/s Dense
Problems
Solution: multi level index
Multi-level Index helps breaking down the index into several smaller indices in order to make the outer most level so small that it can be saved in single disk block which can easily be accommodated anywhere in the main memory.
Sequential File
20
10
40
30
60
50
80
70
100
90
Sparse 2nd level
10
30
50
70
90
110
130
150
170
190
210
230
10
90
170
250
330
410
490
570
Another problem
{ Example 1: In the EMPLOYEE database, records are stored sequentially by EmpNo, we want to find employees working in a particular department.
{ Example 2: as above, but we want to find all employees with a specified salary or range of salary
Secondary indices
Secondary indices
Primary v/s secondary indices
Dynamic multilevel indexing using B+ tree
B+ tree node structure
K1 < K2 < K3 < . . . < Kn–1
Insertion into B+ tree
Example
Assume n=4 or degree=4;
Insert 2:
Insert 5:
2
2
5
Insert 10:
No space how can I insert?
2
5
7
2
5
7
2
5
7
10
7
2
5
7
10
13
7
7
10
13
16
7
10
13
13
16
2
5
7
10
7
13
13
16
20
2
5
7
10
7
13
13
16
2
5
7
10
7
13
20
20
22
13
16
2
5
7
10
7
13
20
20
22
23
overflow root
20
22
23
23
24
20
22
7
13
20
If node is non leaf node then break down the node into two partitions.
13
16
2
5
7
10
7
23
24
20
22
20
23
13
B+ tree deletion
Leaf node deletion
9
10
13
14
16
13
18
Delete 10
9
13
14
16
14
18
Non leaf node deletion
3
8
5
20
3
1
5
8
20
1
33
34
38
19
20
22
24
27
29
24
30
39
5
13
17
33
34
38
20
22
24
27
29
24
30
39
33
34
38
22
24
27
29
27
30
39
33
34
38
22
27
29
29
30
39
33
34
38
22
27
29
30
39
33
34
38
22
27
29
30
39
5
13
17
33
34
38
22
27
5
13
17
30
39
Nonleaf node – pointers Bi are the bucket or file record pointers.
B Tree
B+ Tree
Advantages of B+ trees:
Advantage of B trees:
Other issues in Indexing