Database Flashcards

1
Q

What is an index?

A

We use indexes in relational databases to improving performance. Indexes are used to speed up query processes by providing quick access to data tables.

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

What is a key?

A

A subset of columns that allow a record/row to be uniquely identified. A unique identifier.

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

What is an inner join?

A

An inner join returns rows from both tables when there is a match on join criteria.

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

What is a join?

A

in SQL we use joins to query multiple tables with related information.

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

What is a transaction?

A

A transaction allows us to execute several related SQL statements before committing changes to the database. To ensure consistency and reliability they all either succeed together or fail together.

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

What are some considerations/ best practices for index design? HINT THERE IS 5

A

1) Use a few columns on an index of a table that is heavily updated.
2) Use many indexes on tables that contain a lot of data and are not often modified.
3) No need to use indexes on small tables might take longer to scan the index.
4) The more unique the values the better the index performs. indexed columns especially clustered index columns should be as unique as possible.
5) Bulk inserts/Mods is better for index performances as well.

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

What are some disadvantages of indexes?

A

1) Indexes can take up a lot of disk space to create and manage, so you don’t want to have too many of them.
2) An index can hurt performance when it’s created on a table that is heavily updated. every time a row is updated the index needs to be updated as well.

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

What are the two types of indexes?

A

Clustered index and non-clustered index.

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

What is a clustered index?

A

A clustered index stores the actual data row at the leaf node of the index. You can only have one clustered index per table and works best on columns whose values are naturally in ascending order and unique.

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

What is a non clustered index?

A

A non-clustered index stores the value of the indexed column and a pointer to the row.

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

What is the difference between a clustered and non clustered index?

A

The main difference is how they store their value. clustered indexes store the entire data row at the leaf node of the index, non clustered indexes only store the indexed column and pointer to the row on the table. You can have many non clustered indexes per table, but only one per clustered index per table.

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

How do indexes work?

A

When a query is performed against an indexed column it searches the index till it finds the leaf node that matches.

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

Describe an index.

A

Distinct structure in relational databases that helps speed up database performance. It uses a B-tree structure. because of this updating, an index can be expensive.

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