Podcast
Questions and Answers
What is a minor disadvantage of B+-trees?
What is a minor disadvantage of B+-trees?
Which statement accurately describes the use of indices in databases?
Which statement accurately describes the use of indices in databases?
Which command would you use to delete an existing index in SQL?
Which command would you use to delete an existing index in SQL?
Why are indices on primary keys created automatically by databases?
Why are indices on primary keys created automatically by databases?
Signup and view all the answers
What advantage do B+-trees offer over other types of trees?
What advantage do B+-trees offer over other types of trees?
Signup and view all the answers
What is the purpose of the 'create unique index' command in SQL?
What is the purpose of the 'create unique index' command in SQL?
Signup and view all the answers
What role do index tuning assistants play in database management?
What role do index tuning assistants play in database management?
Signup and view all the answers
What is an example of a SQL command to create an index?
What is an example of a SQL command to create an index?
Signup and view all the answers
What is the main purpose of indexing in a database system?
What is the main purpose of indexing in a database system?
Signup and view all the answers
In which type of index are search keys stored in sorted order?
In which type of index are search keys stored in sorted order?
Signup and view all the answers
What distinguishes a clustering index from a secondary index?
What distinguishes a clustering index from a secondary index?
Signup and view all the answers
Which of the following statements is true regarding dense index files?
Which of the following statements is true regarding dense index files?
Signup and view all the answers
What mechanism does a hash index use to distribute search keys?
What mechanism does a hash index use to distribute search keys?
Signup and view all the answers
Which type of index provides a record for only some search-key values?
Which type of index provides a record for only some search-key values?
Signup and view all the answers
What is typically true about the size of index files compared to the original file?
What is typically true about the size of index files compared to the original file?
Signup and view all the answers
Which index is also known as a nonclustering index?
Which index is also known as a nonclustering index?
Signup and view all the answers
What is the primary disadvantage of indexed-sequential files as mentioned?
What is the primary disadvantage of indexed-sequential files as mentioned?
Signup and view all the answers
Which indexing technique is generally slower when locating records?
Which indexing technique is generally slower when locating records?
Signup and view all the answers
What is a characteristic of secondary indices?
What is a characteristic of secondary indices?
Signup and view all the answers
What is a benefit of using a B+-tree index file?
What is a benefit of using a B+-tree index file?
Signup and view all the answers
What is the purpose of using a sparse index in the context of clustering?
What is the purpose of using a sparse index in the context of clustering?
Signup and view all the answers
What happens when a record is updated in the context of maintaining indices?
What happens when a record is updated in the context of maintaining indices?
Signup and view all the answers
What does a multi-level index allow when the basic index is too large for main memory?
What does a multi-level index allow when the basic index is too large for main memory?
Signup and view all the answers
What is a common overhead associated with maintaining indices on a database?
What is a common overhead associated with maintaining indices on a database?
Signup and view all the answers
Study Notes
Basic Concepts
- Indexing is used to speed up access to data by creating an index file that contains records (index entries) of the form: search-key - pointer
- The index file is typically much smaller than the original file
- Two basic kinds of indices are ordered indices and hash indices
Ordered Indices
- Ordered indices store index entries sorted on the search key value
- A clustering index specifies the sequential order of a file
- A clustering index is also called a primary index
- A secondary index specifies a different order than the sequential order of the file
- A secondary index is also called a non-clustering index
- An index-sequential file is a sequential file ordered on a search key, with a clustering index on the search key
Dense Index Files
- A dense index has an index record for every search-key value in the file
- Dense indices are efficient for locating records
- Dense indices are also more space consuming and require more maintenance overhead for insertions and deletions
Sparse Index Files
- A sparse index only contains index records for some search-key values
- Sparse indices are suitable for sequentially ordered records
- To locate a record with a search-key value, a sparse index will find the index record with the largest search-key value less than the target search-key value and then search sequentially from the record pointed to by that index record
- Sparse indices are less space consuming and have less maintenance overhead compared to dense indices, but they are generally slower for locating records
- A good tradeoff for a clustered index is a sparse index with an index entry for every block in the file, corresponding to the least search-key value in the block
- For an unclustered index, a sparse index on top of a dense index can be used for multilevel indexing
Secondary Indices Example
- A secondary index on the salary field of the instructor relation can point to a bucket that contains pointers to records with that particular salary value
- Secondary indices must be dense
Clustering vs Non-Clustering Indices
- Indices offer substantial benefits when searching for records, but they impose overhead on database modifications
- For updates, all indices on a relation must be updated when a record is inserted or deleted
- For updates, any index on an updated attribute must be updated if a record is updated
- Sequential scanning using a clustering index is efficient, but it is expensive on magnetic disk for a non-clustering index because each record access may need a new block from disk, which takes about 5-10 milliseconds
Multilevel Index
- A multilevel index is used to efficiently manage large indexes that don't fit in memory
- It involves constructing a sparse index (outer index) on top of the basic index (inner index)
- If the outer index is too large, another level of index can be created, forming a hierarchical structure
- All levels of indices must be updated on insertion or deletion from the file
B+-Tree Index Files
- B+-tree index files offer an advantage over indexed-sequential files by automatically reorganizing themselves with small, local changes during insertions and deletions, thus eliminating the need for periodic reorganization of the entire file
- This reorganization capability makes them efficient even when the file grows
- B+-trees are used extensively due to their advantages
- B+-trees impose minor insertion and deletion overhead and some space overhead
Creation of Indices
- The command
create index <index-name> on <relation> (<attribute-list>)
is used to create indices - The command
drop index <index-name>
is used to drop indices - Indices on primary keys are created automatically by all database systems
- Some database systems also create indices on foreign key attributes, which can speed up joins
- Indices can significantly speed up lookups but impose costs on updates
- Index tuning assistants/wizards are available in several databases to help in choosing indices based on query and update workload
Index Definition in SQL
- An index can be created using the command
CREATE INDEX <index-name> ON <table-name> (<column-list>)
- The command
CREATE UNIQUE INDEX
can be used to indirectly specify and enforce the condition that the search key is a candidate key - An index can be dropped using the command
DROP INDEX <index-name>
- Most database systems allow the specification of index type and clustering
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers the fundamental concepts of indexing in database management, including ordered and dense indices. Learn the difference between clustering and secondary indices, and explore how indexing helps improve data retrieval efficiency.