0
0
DBMS Theoryknowledge~10 mins

B-tree index structure in DBMS Theory - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a B-tree index on the column 'name' in SQL.

DBMS Theory
CREATE INDEX idx_name ON employees ([1]);
Drag options to blanks, or click blank then click option'
Aname
Bage
Cdepartment
Dsalary
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a column unrelated to the query, like 'age' or 'salary'.
Forgetting to specify the column name.
2fill in blank
medium

Complete the SQL query to find all employees with names starting with 'A' using the B-tree index.

DBMS Theory
SELECT * FROM employees WHERE name [1] 'A%';
Drag options to blanks, or click blank then click option'
A=
BLIKE
CIN
DBETWEEN
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which looks for exact matches only.
Using 'IN' which is for lists of values.
3fill in blank
hard

Fix the error in the SQL statement to create a B-tree index explicitly.

DBMS Theory
CREATE INDEX idx_salary ON employees (salary) USING [1];
Drag options to blanks, or click blank then click option'
Agin
Bhash
Cgist
Dbtree
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hash' which is a different index type.
Using 'gist' or 'gin' which are for other data types.
4fill in blank
hard

Fill both blanks to complete the B-tree node split condition in pseudocode.

DBMS Theory
if (node.[1] > [2]) {
    splitNode(node);
}
Drag options to blanks, or click blank then click option'
AkeysCount
BmaxKeys
CminKeys
DchildrenCount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'minKeys' which is the minimum, not the maximum.
Using 'childrenCount' which is not the key count.
5fill in blank
hard

Fill all three blanks to complete the B-tree search pseudocode for a key.

DBMS Theory
function search(node, key) {
    let i = 0;
    while (i < node.[1] && key > node.keys[[2]]) {
        i = i + 1;
    }
    if (i < node.[3] && key == node.keys[i]) {
        return node.values[i];
    }
    if (node.isLeaf) {
        return null;
    } else {
        return search(node.children[i], key);
    }
}
Drag options to blanks, or click blank then click option'
AkeysCount
Bi
DchildrenCount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'childrenCount' instead of 'keysCount' for key comparisons.
Using wrong index variables in conditions.