DBMS1 Week 4
DBMS1 Week 4
References/Resources:
R. Elmasri, S.B. Navathe, “Fundamentals of Database Systems”, 6th Edition,
Pearson Education
Secondary Indexes
The secondary index (in both on a key and nonkey field) is an ordered file with two fields.
• The first field is of the same data type as some nonordering field of the data file that is an
indexing field.
• The second field is either a block pointer or a record pointer.
2
Secondary Indexes on key field
• It is has distinct value for every record.
• It is a dense index.
• In this case there is one index entry for each record in the data file, which contains
the value of the field for the record and a pointer either to the block in which the
record is stored or to the record itself.
• We cannot use block anchor because data file is unordered.
Disadvantages
• It is requires more storage space.
• The search time is long than a primary index, because of its larger no. of entries.
3
Values are
unique,
Block pointer not ∵ key field
record pointer
NOTE:
Based on
key value
(hence
unique) and
the data file
is unordered. 4
Secondary Index on Nonkey field
Option 2 Option 3
Option 1
6
Option 3
Contains all
pointers of
record 1
Contains all
pointers of
record 8
NOTE:
Based on
nonkey
value (hence
duplicate)
and the data
file is
unordered. 7
Advantage of Option3
Insertion and deletion of records in the data file is faster.
Disadvantage of Option3
Retrieval via the index requires one or more additional block accesses because of the
extra level.
8
Multi
Primary
index of the level
first level
Index
9
Multilevel Indexes
• It considers the index file, the first (or base) level of a multilevel index, as an
ordered file with a distinct value for each K(i).
• Create a primary index for the first level; this index to the first level is called the
second level of the multilevel index.
• The second level has one entry for each block of first level.
• The value 𝑏𝑓𝑟𝑖 is called the fan-out of the multilevel index and it denoted by fo.
• All index entries are the same size with one field value and one pointer.
• If the first level has 𝒓𝒊 entries and the blocking factor for the index is fo then, the
𝒓𝟏
no. of entries 𝒓𝟐 = are needed at the second level of index.
𝒇𝒐
B+ Trees
Data records of data file are exits in leaf node.
11