Lecture 5 - B Flashcards
(14 cards)
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.
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.
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.
4
Q
B- Tree
A
- Each node contains key values , value pointers and pointers to child nodes.
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)
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.
7
Q
B+ tree index 3 properties:
A
What differs B+ and B- is the way data pointers are stored.
- Perfectly balanced
- Every inner node other than the root is at least half full.
- Every inner node with k keys has k+1 non-null children.
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.
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.
10
Q
Indexes drawbacks:
A
- Indexes need to be mantained
- Indexes need to be stored
11
Q
When changing large amounts of data:
A
- DROP the index
- Run many statements.
- Recreate the index.
12
Q
EXPLAIN
A
The EXPLAIN statement provides information about how DBMS executes statements.
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.
14
Q
Why use views?
A
- Security, compliance and privacy.
- Data aggregation.
- Hiding complexity.
- Joining partitioned data