Professional Documents
Culture Documents
Alternatives 2 and 3:
Data entries typically much smaller than
data records.
• So, better than Alternative 1 with large
data records, especially if search keys are
small.
Alternative 3 more compact than Alternative
2.
• But leads to variable sized data entries
even if search keys are of fixed length.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 7
Index Classification
Primary vs. secondary: If search key contains primary
key, then called primary index; other indexes are
secondary.
Unique index: Search key contains candidate key that uniquely
identifies record.
An index that uses alternative 1 is primary index.
An index that uses alternatives 2 or 3 are secondary index.
Clustered vs. unclustered: If order of data records is the
same as, or close to, order of data entries, then called
clustered index; otherwise it is unclustered index.
Alternative 1 implies clustered; in practice, clustered also
implies Alternative 1 (since sorted files are rare).
A file can be clustered on at most one search key.
Cost of retrieving data records through index varies greatly
based on whether index is clustered or not!
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 8
1. Dense Index 2. Sparse Index
In Dense Index, there is an In this index based system, the
index for every record in the indexes of very few data items
database. If more than one are maintained in the index
record has the same search key file. Indexes are limited to one
then the dense index points to per block of data items.
the first record in the database
that has the search key. In sparse indexing database needs to
The dense name is given to this be sorted in an order.
index is based on the fact that
every record in the database has
a corresponding index in index
file so the index file is very dense
in this index based database.
Index entries
CLUSTERED direct search for UNCLUSTERED
data entries
The B+ tree is an index structure that ensures that all paths from
the root to a leaf in a given tree are of the same length, that is, the
structure is always balanced in height.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 13
B+ Tree Indexes
Non-leaf
Pages
Leaf
Pages
Leaf pages contain data entries, and are chained (prev & next)
Non-leaf pages contain index entries; they direct searches:
index entry
P0 K 1 P1 K 2 P 2 K m Pm
17
5 13 27 30
2* 3* 5* 7* 8* 14* 16* 22* 24* 27* 29* 33* 34* 38* 39*