Lecture 19+20 Flashcards
What is a multilevel index? What can it be used with?
First level is an ordered file, the second level is a primary index of the first and so on. This can be used on primary, clustering, or secondary indexes. Though there are problems with insertion and deletion.
They basically function like search trees.
What are the requirements of a search tree of order p?
Each node has at most p-1 search values, and p pointers, each pointer points to a child or a NULL. All search values should be unique, there must always be exactly one less search value than pointers and all values in child trees should be less than the search value.
Why are search trees not guaranteed to be balanced by default?
Tree balance is sensitive to insertion order. Also deletion can lead to nodes which are close to empty.
What is a B-Tree?
A search tree, but the tree must always be balanced, and space wasted by deletion, if any, must never be excessive.
To achieve this:
Each node must be at least half full(except root and leaf nodes).
A node has 1 less search key field values than pointers.
All leaf nodes must be at the same level, and must point to NULL.
What is a B+ tree?
B-tree variant, all data pointers are stored only in leaf nodes. Leaf node structure differs from internal node structure, and are typically linked together to allow for ordered access. More entries can be packed into an internal node for a B+ tree than a B tree due to no data pointers in internal nodes of B+
What are the nodes of a B+ tree like?
Each internal node has one less search key field than pointers and pointers >= the order of the tree. All values in subtree should stay within the brackets of the search field values they came from.
Each leaf node has a key field and a pointer pairing, up until the final pointer, which is a pointer to the next leaf of the B+ tree. Each leaf node has at least order/2 values and all leaf nodes are at the same level.
What is a B* tree?
A B+ tree, but each node must be 2/3 full.
What are the disadvantages of indexes?
Add overhead when inserting, deleting, and possibly updating.
Indexes should be added after the data in the event of a mass load.
How do we create and drop indexes in SQL?
CREATE INDEX ON (column);
DROP INDEX
What is security with regards to databases?
Protection of the database against unauthorized access, either intentional or accidental.
What are the main control measures?
Access control: user account and password.
Inference Control: statistical database security.
Flow Control: prevent information from reaching unauthorized users.
Data encryption: Protect sensitive data.
Who is responsible for access control? How is it done?
The database administrator. They have an account known as the superuser, it allows for account creation for overall access, privilege granting and revocation(discretionary), and security level assignment(mandatory).
What are the two approaches to DB security?
Discretionary: this is done in most commercial DBMSs. A user may have different access rights to different objects, different users may have different rights on the same object. This is very flexible.
Mandatory: Used in some DBMS for government/military type operations.
Each object tagged with classification level, each user has a level, the data object can only be accessed by users with appropriate clearance. This is very rigid.
How does mandatory access control work?
There are 4 levels: top secret > secret > confidential > none. Users can not read higher than their rank and can not write lower than their rank. This prevents lowering the security of objects.
How does discretionary access control work?
granting and revoking of privileges, providing selective access to relations based on specific users. Two levels are account level(different rights on same object) and relation level(different access rights to different objects).
Each table has an owner, they can grant privileges to their tables, types of privileges are SELECT, MODIFY or REFERENCES (can be referenced in constraints). Or views.
GRANT gives privileges to tables, REVOKE removes them.