0% found this document useful (0 votes)
20 views26 pages

Chapter - 2 - Revision

The document discusses different types of indexes that can be used to improve the efficiency of retrieving records from a database. It describes single-level indexes including primary indexes, clustering indexes and secondary indexes. It also covers multi-level indexes, indexes on multiple keys, hash indexes, bitmap indexes and function-based indexes. General issues around indexing and tuning indexes are also discussed.

Uploaded by

almaraniabwmalk
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)
20 views26 pages

Chapter - 2 - Revision

The document discusses different types of indexes that can be used to improve the efficiency of retrieving records from a database. It describes single-level indexes including primary indexes, clustering indexes and secondary indexes. It also covers multi-level indexes, indexes on multiple keys, hash indexes, bitmap indexes and function-based indexes. General issues around indexing and tuning indexes are also discussed.

Uploaded by

almaraniabwmalk
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/ 26

Copyright © 2016 Ramez Elmasri and Shamkant B.

Navathe
CHAPTER 2

Indexing Structures for Files and


Physical Database Design

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe


CHAPTER OUTLINE
➢ Introduction
➢ Indexes as Access Paths
➢ Single Level Indexes
➢ Types of Single-Level Indexes
➢ Primary Indexes
➢ Clustering Indexes
➢ Secondary Indexes
➢ Properties of Index Types
➢ Multilevel Index
➢ Types of Indexes

❖ CLO to be covered –CLO 1.1 (Knowledge and Understanding)


Define the basic concepts of DBMS and Comparison of indexing techniques.

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 3


Introduction
◼ Indexes used to speed up record retrieval in
response to certain search conditions
◼ Index structures provide secondary access paths
◼ Any field can be used to create an index
◼ Multiple indexes can be constructed
◼ Most indexes based on ordered files
◼ Tree data structures organize the index

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 16- 4


Types of Single-Level Ordered
Indexes
◼ Ordered index similar to index in a textbook
◼ Indexing field (attribute)
◼ Index stores each value of the index field with list
of pointers to all disk blocks that contain records
with that field value
◼ Values in index are ordered
◼ Primary index
◼ Specified on the ordering key field of ordered file
of records

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 5


Types of Single-Level Ordered
Indexes (cont’d.)
◼ Clustering index
◼ Used if numerous records can have the same
value for the ordering field
◼ Secondary index
◼ Can be specified on any nonordering field
◼ Data file can have several secondary indexes

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 6


Primary Indexes
◼ Ordered file with two fields
◼ Primary key, K(i)
◼ Pointer to a disk block, P(i)
◼ One index entry in the index file for each block in
the data file
◼ Indexes may be dense or sparse
◼ Dense index has an index entry for every search
key value in the data file
◼ Sparse index has entries for only some search
values
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 7
Primary Indexes (cont’d.)

Figure 17.1 Primary index on the ordering key field of the file shown in Figure 16.7
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17-8
What is the major problem with...

Primary Indexes (cont’d.)


◼ Major problem: insertion and deletion of records
◼ Move records around and change index values
How can primary indexes' problem be solved?
◼ Solutions

◼ Use unordered overflow file


◼ Use linked list of overflow records

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 9


Clustering Indexes
◼ Clustering field
◼ File records are physically ordered on a nonkey
field without a distinct value for each record
◼ Ordered file with two fields
◼ Same type as clustering field
◼ Disk block pointer

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 10


Clustering Indexes (cont’d.)

Figure 17.2 A clustering index on the Dept_number ordering


nonkey field of an EMPLOYEE file
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17-11
Secondary Indexes
◼ Provide secondary means of accessing a data file
◼ Some primary access exists
◼ Ordered file with two fields
◼ Indexing field, K(i)
◼ Block pointer or record pointer, P(i)
◼ Usually need more storage space and longer
search time than primary index
◼ Improved search time for arbitrary record

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 12


Secondary Indexes (cont’d.)

Figure 17.4 Dense


secondary index (with
block pointers) on a
nonordering key field
of a file.

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17-13


Types of Single-Level Ordered
Indexes (cont’d.)

Table 17.1 Types of indexes based on the properties of the indexing field

Table 17.2 Properties of index types


Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17-14
Multilevel Indexes
◼ Designed to greatly reduce remaining search
space as search is conducted
◼ Index file
◼ Considered first (or base level) of a multilevel
index
◼ Second level
◼ Primary index to the first level
◼ Third level
◼ Primary index to the second level

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 15


Figure 17.6 A two-level
primary index resembling
ISAM (indexed sequential
access method) organization

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17-16


Indexes on Multiple Keys
◼ Multiple attributes involved in many retrieval and
update requests
◼ Composite keys
◼ Access structure using key value that combines
attributes
◼ Partitioned hashing
◼ Suitable for equality comparisons

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 17


Indexes on Multiple Keys (cont’d.)
◼ Grid files
◼ Array with one dimension for each search attribute

Figure 17.14 Example of a grid array on Dno and Age attributes

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 18


Other Types of Indexes
◼ Hash indexes
◼ Secondary structure for file access
◼ Uses hashing on a search key other than the one
used for the primary data file organization
◼ Index entries of form (K, Pr) or (K, P)
◼ Pr: pointer to the record containing the key
◼ P: pointer to the block containing the record for that
key

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 19


Hash Indexes (cont’d.)

Figure 17.15 Hash-based indexing


Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17-20
Bitmap Indexes
◼ Used with a large number of rows
◼ Creates an index for one or more columns
◼ Each value or value range in the column is
indexed
◼ Built on one particular value of a particular field
◼ Array of bits
◼ Existence bitmap
◼ Bitmaps for B+ -tree leaf nodes

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 21


Function-Based Indexing
◼ Value resulting from applying some function on a
field (or fields) becomes the index key
◼ Introduced in Oracle relational DBMS
◼ Example
◼ Function UPPER(Lname) returns uppercase
representation

◼ Query

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 22


Some General Issues Concerning
Indexing
◼ Physical index
◼ Pointer specifies physical record address
◼ Disadvantage: pointer must be changed if record
is moved
◼ Logical index
◼ Used when physical record addresses expected to
change frequently
◼ Entries of the form (K, Kp)

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 23


Tuning Indexes
◼ Tuning goals
◼ Dynamically evaluate requirements
◼ Reorganize indexes to yield best performance
◼ Reasons for revising initial index choice
◼ Certain queries may take too long to run due to
lack of an index
◼ Certain indexes may not get utilized
◼ Certain indexes may undergo too much updating if
based on an attribute that undergoes frequent
changes

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 24


Summary
◼ Indexes are access structures that improve
efficiency of record retrieval from a data file
◼ Ordered single-level index types
◼ Primary, clustering, and secondary
◼ Multiple key access methods
◼ Logical and physical indexes

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 17- 25


REVIEW QUESTIONS
1. Write a note on Indexes.
2. Discuss about the types single level indexes.
3. Describe about the Primary indexes with a neat diagram.
4. How a clustering index is implemented? Explain with an example.
5. Write short notes on secondary indexes.
6. Tabulate the ttypes of indexes based on the properties of the indexing field.
7. Tabulate the properties of Index types.
8. Write short notes on Multilevel Indexes.
9. Discuss about Indexes on Multiple keys.
10. Write a note on Hash Indexes.
11. Write a note on Bitmap Indexes.
12. Write short notes on function-based indexing. Give one example.
13. List out eh general issues in Indexing.
14. What are the tuning goals of an index.
15. State the reasons for revising initial Index choice.

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 16- 26

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