Week 2 - Major Indexing Schemes Flashcards

1
Q

Hash Indexes what is it good for ?

A

1) Hash-based indexes are good for equality selections
(age =16, id=2)
2) takes keys and puts data in data bucket

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What kind of indexing scheme should be used in order to retrieve data on customers whose zip code is equal to 06902?

1) Equality index
2) Clustered index
3) Heap-based index1
4) Hash-based index

A

4) Hash-based index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Index entries have what

A

Have pointers to where that data is.

So, the index entries help you just navigate,
so it help you search,
and the data entries are the last level where you go ahead, and retrieve the data from where it’s stored in the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Ways to store data entries

A

1) key (record ID)

2) Key (list of record IDs)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

We know that data is stored in the form of records. Every record has a?

A

key field

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

An ______ is a data structure that locates these key fields within the database file

A

index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a clustered index

A

Data records are sorted like the data is sorted. Stored by the attribute (like an id)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

un-clustered index

A

The record is not sorted by the data.

Note same sorting order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What type of index should you use?

A

Depends on workload

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Where should you put the index if all the queries access the same attribute

A

1) The index should be on that attribute (what is in the WHERE )
2) how what percentage of the data is selected Lower the better

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

IF the query selects 95% of data is that a good place to put and index

A

No

Lower is better (more refined)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Cost of Indexes

A

1) storage (hard disk space)
2) If there are lots of inserts can be slower
3) Maintain index (hard if updating it a lot)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

If a database has m rows and n columns, what is the maximum number of clustered indexes for this table?

1) 1
2) n
3) mn
4) m

A

1) 1

A database table can only have one clustered index.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Four considerations for creating a new index

A

1) Consider the most important queries
2) Consider the best plan using the current indexes
3) Determine if a better plan is possible with an additional index
4) How often the index needs to be updated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

4 Index selection Guidelines

A

1) Attribute in the WHERE clause
2) Keys (primary, unique attribute)
3) Searches on multiple attribute
4) If index will benefit multiple queries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

B+ tree index are good for

A

IDs, numbers, group by

17
Q

HASHed indexs are good for

A

Equality WHERE hobby = stamps

18
Q

Composite Keys

A

Composite index (index on two or more values)

19
Q

In a composite index which is given priority?

A

age

First item is given priority

20
Q

Can you ever find all the info you need without going to the table

A

Yes, sometimes the index has everything you need.

Example:
Index based on departmentNumber

Select E.departmentNumber from Emp E GROUP BY E.departmentNumber ;

21
Q

Creating indexes is not a straightforward decision because of the costs involved. One must answer certain questions before creating indexes. Which of the following questions is NOT relevant to creating an index?

1) Which field(s) should be part of an index?
2) Which tables should be indexed?
3) Should one build multiple indexes?
4) Which record(s) should be part of an index?

A

4) Which record(s) should be part of an index?

This question is irrelevant to building indexes; an index is built using fields, not records.

22
Q

Which of the following database operations can be achieved by using hash-based indexes?

1) To retrieve student data where age is equal to 20.
2) To retrieve student data where age is between 18 and 20.
3) To retrieve student data where age is different than 20.
4) To retrieve student data where age is less than 20.

A

1) To retrieve student data where age is equal to 20.

Hash-based indexes are good for equality selections.

23
Q

If a database table has m rows and n columns, what is the maximum number of clustered indexes for this table?

1) 1
2) m
3) n
4) mn

A

1) 1

A database table can only have one clustered index.

24
Q

Which of the following is/are among the disadvantages of indexes? Choose all that apply.

1) Increased cost of storage.
2) Increased cost of maintenance.
3) Decrease in performance of select queries.
4) Decrease in performance of update queries.

A

1) Increased cost of storage.

2) Increased cost of maintenance.