Professional Documents
Culture Documents
Secondary Indexes
There are 3 general ways to access a table:
Primary Index access
(CREATE TABLE)
(CREATE INDEX)
USI
If the index choice of column(s) is
unique, it is called a USI.
Unique Secondary Index)
CREATE INDEX
(Employee_Number) ON Employee;
(Last_Name) ON Employee;
Notes:
Secondary Indexes cause an internal sub-table to be built.
Create USI
CREATE UNIQUE INDEX
(Cust) ON Customer;
AMP 1
AMP 2
USI Subtable
RowID
244, 1
505, 1
744, 4
757, 1
SELECT *
FROM
Customer
WHERE Cust = 56;
Cust
74
77
51
27
RowID
884, 1
639, 1
915, 9
388, 1
AMP 3
USI Subtable
RowID
135, 1
296, 1
602, 1
969, 1
Cust
98
84
56
49
Table ID
100
to MPL
56
Cust
31
40
45
95
RowID
638, 1
640, 1
471, 1
778, 3
RowID
175, 1
489, 1
838, 4
919, 1
Cust
37
72
12
62
RowID
107, 1
717, 2
147, 2
822, 1
778
USI Value = 56
Hashing
Algorithm
RowID
288, 1
339, 1
372, 2
588, 1
USI Subtable
100
Customer
Table ID = 100
USI Subtable
RowID
555, 6
536, 5
778, 7
147, 1
Table ID
PE
AMP 4
AMP 1
AMP 2
AMP 3
AMP 4
Base Table
Base Table
Base Table
Base Table
Phone
NUPI
555-4444
666-5555
111-2222
222-3333
Phone
NUPI
444-6666
333-9999
666-7777
555-6666
Phone
NUPI
111-6666
777-4444
222-8888
444-5555
Phone
NUPI
777-6666
555-7777
555-7777
888-2222
Create NUSI
AMP 1
AMP 2
NUSI Subtable
RowID
432, 8
448, 1
567, 3
656, 1
Name
Smith
White
Adams
Rice
RowID
640, 1
107, 1
638, 1
536, 5
AMP 3
NUSI Subtable
RowID Name
432, 3 Smith
567, 2 Adams
852, 1
Brown
RowID
884, 1
471, 1
717, 2
555, 6
AMP 4
NUSI Subtable
RowID
432, 1
448, 4
567, 6
770, 1
Name
Smith
Black
Jones
Young
RowID
147, 1
822, 1
338, 1
147, 2
NUSI Subtable
RowID
155, 1
396, 1
432, 5
567, 1
Name
Marsh
Peters
Smith
Jones
RowID
915, 9
778, 3
778, 7
639, 1
PE
Customer
NUSI Value = 'Adams'
Table ID = 100
Hashing
Algorithm
Table ID
100
to MPL
AMP 2
Base Table
AMP 1
Adams
Phone
NUPI
555-4444
666-5555
111-2222
222-3333
AMP 3
Base Table
RowID Cust Name
NUSI
471, 1 45 Adams
555, 6 98 Brown
717, 2 72 Adams
884, 1 74 Smith
Phone
NUPI
444-6666
333-9999
666-7777
555-6666
AMP 4
Base Table
RowID Cust Name
NUSI
147, 1 49 Smith
147, 2 12 Young
388, 1 27 Jones
822, 1 62 Black
Phone
NUPI
111-6666
777-4444
222-8888
444-5555
Base Table
RowID Cust Name
NUSI
639, 1 77 Jones
778, 3 95 Peters
778, 7 56 Smith
915, 9 51 Marsh
Phone
NUPI
777-6666
555-7777
555-7777
888-2222
Primary
Secondary
Yes
No
0 - 32
16
16
64
64
Unique or Non-unique
Both
Both
Yes
No
Created/Dropped Dynamically
No
Yes
Improves Access
Yes
Yes
Yes
Yes
No
Sub-table
No
Yes
Yes
No
Cust_Name
Cust_Phone
NUPI
Review Questions
Fill each box with either Yes, No, or the appropriate
number.
USI
Access
# AMPs
# rows
Parallel Operation
Uses Hash Maps
Uses Separate Sub-table
Reads all data blocks of table
NUSI
Access
FTS
NUSI
Access
FTS
# AMPs
All
All
# rows
0-1
0-n
0 - all
Parallel Operation