Lecture 5 - B Flashcards

1
Q

Clustered index

A
  • The unique index per table that uses a primary key to organize the data that is within the table.
  • Ensures that the primary key is stored in increasing order, which is also the order the table holds in memory.
  • Do not have to be mentioned, uses the primary key to be stored in ascending order.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Non-clustered indexes

A
  • Sorted references for a specific field, from the main table, that hold pointers back to the original entries of the table.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Value Pointers

A

Non-clustered indexes store value pointers, not values themselves.

  • The pointers with the key used can be used to immediately locate a record in the indexed table.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

B- Tree

A
  • Each node contains key values , value pointers and pointers to child nodes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

B+ Tree

A
  • Same as B- but leaf nodes are linked.
  • Is a self-balancing tree data structure that keeps data sorted and allows searches, sequential access, insertion, deletion in O(log n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Advantages of B- trees

A
  • Can find values closer to the root fairly quickly.
  • In B+ we would have to look all the way down to the leaf nodes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

B+ tree index 3 properties:

A

What differs B+ and B- is the way data pointers are stored.

  1. Perfectly balanced
  2. Every inner node other than the root is at least half full.
  3. Every inner node with k keys has k+1 non-null children.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Hash Table indexes, 2 properties:

A
  • Very fast (O(1)) when querying for equality, since it uses the whole key as the lookup value.
  • Can’t help us find the range, use > < or ORDER BY instead.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Use of an indexes

A
  • Foreign keys, to speed up joins
  • Often queries fields, dates are often good candidates.
  • Columns that have many different values.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Indexes drawbacks:

A
  • Indexes need to be mantained
  • Indexes need to be stored
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When changing large amounts of data:

A
  1. DROP the index
  2. Run many statements.
  3. Recreate the index.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

EXPLAIN

A

The EXPLAIN statement provides information about how DBMS executes statements.

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

VIEWS

A

Views give you the ability to store query results as if they were tables.

  • By default, a view does not use any shortage, when queried it always presents the latest data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why use views?

A
  1. Security, compliance and privacy.
  2. Data aggregation.
  3. Hiding complexity.
  4. Joining partitioned data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly