You are on page 1of 11

Example 1.

Non-Dense (Primary) Index,


ONE FREE matches file ordering
Index
111 121 1113
235 121 2311
266 333 4343

Search for
235 122 4993

Records
111 121 1112
111 131 2143
121 234 4544
121 349 6341

block

235 121 2311


235 122 4993

block

266 333 4343

block

INLS 623 Indexing examples BMH/SWH

Example 2. (Clustered) Non-Dense Index


(ONE FREEmatches file ordering)
Index
Blue
Green
Grey
Red
Yellow

Records
Blue 2
Blue 3
Blue 9
Green 1
Green 2

block

Green 6
Grey 1
Red 1

block

Red 9
Red 10
Yellow 6
INLS 623 Indexing examples BMH/SWH

block

Example 3. Secondary (Dense) Index


Index
Blue
Blue
Blue
Green
Green
Green
Yellow
Yellow
Yellow

1 entry per record


Records
12
14
15
17
19
23
29
33
43

Blue
Yellow
Green
Yellow
Blue
Yellow
Green
Green
Blue

INLS 623 Indexing examples BMH/SWH

Example 4. Secondary (Dense) Index


Index

Blue
Green
Yellow

1 entry per value, all addresses


Records
12
14
15
17
19
23
29
33
43

Blue
Yellow
Green
Yellow
Blue
Yellow
Green
Green
Blue

INLS 623 Indexing examples BMH/SWH

Example 5. Secondary (Dense) Index


1 entry per value, address to addresses
Index

Addresses

Records
12
14
15
17
19
23
29
33
43

Blue
Green
Yellow

INLS 623 Indexing examples BMH/SWH

Blue
Yellow
Green
Yellow
Blue
Yellow
Green
Green
Blue

Example 6. Multilevel Index


First Level

Second Level
1
15

25
52

25
39
52

INLS 623 Indexing examples BMH/SWH

Records
1
3
4
15
23
24
25

39
42

52
53

Example 7a. B+ Tree Node Structure

p1

Node 1

v1

p2

Node 2

v2

p3

v3

Node 3

p4

v4

Node 4

INLS 623 Indexing examples BMH/SWH

p5

Node 5

Example 7b. B+ Tree Node Structure

p1

15

p2

30

p3

50

p4

93

31 33 47 50

1 12 15
16 21 24 30

p5
94 99 103

51 56 78 81 93

INLS 623 Indexing examples BMH/SWH

Hashing
Function(value) = location (i.e. bin)
Example: Mod 13 of (SSN) =
123-45-6789 mod 13 = 1
234-56-7899 mod 13 = 7
864-93-5196 mod 13 = 8
963-77-5936 mod 13 = 6
058-32-9744 mod 13 = 5
532-87-1523 mod 13 = 2
274-98-6648 mod 13 = 1
INLS 623 Indexing examples BMH/SWH

Bin 1
123-45-6789 mod 13 = 1
274-98-6648 mod 13 = 1

Bin 2
532-87-1523 mod 13 = 2

Bin 3
Bin 4
Bin 5
058-32-9744 mod 13 = 5

Bin 6
963-77-5936 mod 13 = 6

Bin 7
234-56-7899 mod 13 = 7

Bin 8
864-93-5196 mod 13 = 8

. (plus overflow Bin)


INLS 623 Indexing examples BMH/SWH

Indexing Organization Options


File (on Disk)

Index in RAM

Unordered
Ordered

No Index

Ordered

One Free Primary Non-Dense Index (B+Tree)


and possibly
Multiple (costly) Secondary Dense Indexes (B+Tree)

Hash

No physical index

INLS 623 Indexing examples BMH/SWH

You might also like