Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Shahinaz Elmahmoudi

3851893
10 April 2016
Assignment 7
1. describe how indexing works.
Indexes are extra files in the database that provide different and efficient ways to access the
data by using fields in the record. By having this as an extra file, it wont affect the actual
structure of the records. Any field can be used to create an index and there can be multiple
indexes. An index stores the values (in order) from the indexed field and a pointer to records
that have that value. Indexing speeds up search queries by using a search condition on the
indexed field, and instead of searching through all of the records, the index is searched first and
pointers to where the record(s) are located are returned.
2. give five (very very brief) reasons for indexing an attribute.
1. the indexed attribute is queried often
2. to easily be able to uniquely identify tuples
3. indexing an attribute maintains referential integrity constraint
4. indexing improves the speed of searches
5. indexing would be useful if the attribute has a large number of values
3. give a database design consideration when identifying attributes for indexing.
When considering the design of a database, choosing which attributes to index is important. If
the attribute has many unique values, then that attribute should be a primary index. If instead
the attribute has many values but there are many repeats, then it should have a clustered index.
Other factors to consider when choosing an attribute to index is if it has any constraints, such as
the unique or referential integrity constraints; or if the attribute has many nulls that may get in
the way of many of the queries. Another thing to consider would be if the attribute will be
updated constantly or will generally remain the same. If it is updated, it is not a candidate for
indexing. If the indexing an attribute does not greatly improve the speed of the searches, or too
many attributes have already been indexed, then that attribute is likely a bad candidate.
4. there are three (3, tres) types of first-level indexes. what are they and describe each type. do
NOT use examples to describe each type.
Primary indexes - It is an ordered file with records that are distinct and has two fields. The first
field is the same as the primary key and the second is a pointer to a block of addresses. There
is one index entry in the file for each block. The primary index uses less space than the data file
because there are only two fields when a record could have more and because there are
indexes for each block not for each record. A problem with primary indexes is with inserting and
deleting records. When trying to insert or delete a record the index must be completely

restructured in order to fix the anchor records for some of the blocks of data. A primary index is
a nondense index.
Secondary indexes - provides a secondary way of indexing the data. There must already be a
primary or clustering index. The records do not need to be ordered. The index also has only two
fields. The second field can be a block or a record pointer and the first field is the same datatype
as a nonordered field. A secondary index needs more space than a primary index and it also
takes more time to search because it usually has a larger number of entries (since you can have
more than one secondary index). Secondary indexes are also not ordered by its own values, it
is ordered by the primary/clustering index. However, secondary indexes still improve search
times. A secondary index can be either dense or nondense.
Clustering indexes - have records that are physically ordered and have many nondistinct values.
Clustering indexes are used to speed up queries for records of the same value. A clustering
index also uses two fields. The first field is the same type as the field in the data and the second
is a block pointer. There is one entry for each distinct value. Each index contains the value and
a pointer to its block. Record insertion and deletion is also a problem in clustering indexes for
the same reason it is a problem in primary indexing; because the records are ordered. A
clustering index is a nondense index.

You might also like