0% found this document useful (0 votes)
2 views14 pages

DBMS1 Week 4

Chapter 18 discusses indexing structures for files, focusing on secondary indexes for both key and nonkey fields. It explains the characteristics, advantages, and disadvantages of these indexes, including multilevel indexes and B-trees. The chapter emphasizes the importance of efficient indexing for data retrieval and management in databases.

Uploaded by

dojofid610
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views14 pages

DBMS1 Week 4

Chapter 18 discusses indexing structures for files, focusing on secondary indexes for both key and nonkey fields. It explains the characteristics, advantages, and disadvantages of these indexes, including multilevel indexes and B-trees. The chapter emphasizes the importance of efficient indexing for data retrieval and management in databases.

Uploaded by

dojofid610
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter 18

Indexing Structures for


Files

References/Resources:
R. Elmasri, S.B. Navathe, “Fundamentals of Database Systems”, 6th Edition,
Pearson Education
Secondary Indexes

On a key field On a nonkey field with


NOTE: Please see the
duplicate values
eg on slide no.4, then
read the defination.

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.

Please try numerical example 2 and 3

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

Index File Index File


1 1
1 2
2 3
3 Second col a
3 repeating field
for pointers for
Second col duplicate each block
index entry 5
Secondary Index on Nonkey field
Option3 most commonly used
• A single entry for each index field value, and also create an extra level of
indirection to handle the multiple pointers.
• The pointer P(i) in index entry <K(i), P(i)> points to a disk block, which contains a
set of record pointers; each record pointer in that disk block points to one of the
data file records.
• It is a nondense scheme.

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.
𝒇𝒐

• Similarly, third level entries 𝒓3 =


𝒓2
𝒇𝒐

• Multilevel scheme can be used in primary, clustering, or secondary—as long as


the first-level index has distinct values for K(i) and fixed-length entries.
10
B Trees
Data records of data file are either in internal node or in leaf node.

B+ Trees
Data records of data file are exits in leaf node.

No need to study algorithms.

Go through the examples of section 18.3

11

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy