Database Technology

Learn / Database Technology

DBT: INDEXING

Practice set based on indexing screenshots: bitmap index matching, sparse/dense index sizing, extensible hashing, B/B+ trees, and grid-file/hash-index reasoning.

Learning path

0%

0 of 7 sections marked complete · about 35 minutes

Learning objectives

What you will be able to explain

  • Bitmap index matching (students relation)
  • Sparse index size (first level)
  • Second-level sparse index size
  • Extensible hashing after inserting key 1000
  • When inserting a key into a full block of an extensible hash table, if a bucket's local depth is less than global depth, the directory doubles in size.
  • Which of the following statements is true? (B vs B+ Trees)

Section 01

Bitmap index matching (students relation) to Second-level sparse index size

01

Bitmap index matching (students relation)

Correct answer is Option C. It exactly matches ISM/CS bitmaps and all courseID bitmaps (DBT, DBTLAB, ROC, DW).

Guided checkpoint

Consider relation students(studentID, degree, courseID) with bitmap indexes on degree and courseID:

Bitmap index on degree:
ISM:    010101
CS:     101010

Bitmap index on courseID:
DBT:    101000
DBTLAB: 010010
ROC:    000100
DW:     000001

Option A

studentIDdegreecourseID
1CSDBT
2ISMDBTLAB
3CSROC
4ISMDBT
5ISMDBTLAB
6ISMDW

Option B

studentIDdegreecourseID
1CSDBT
2ISMDBTLAB
3CSDW
4ISMDBT
5ISMDBTLAB
6ISMROC

Option C

studentIDdegreecourseID
1CSDBT
2ISMDBTLAB
3CSDBT
4ISMROC
5CSDBTLAB
6ISMDW

Option D

studentIDdegreecourseID
1CSDBT
2ISMDBTLAB
3CSROC
4ISMDBT
5CSDBTLAB
6ISMDW

Which table matches these bitmap indexes?

02

Sparse index size (first level)

Path of calculation: 1. Data blocks = (10,000,000 * 512) / 8192 = 625,000. 2. Sparse index needs one entry per data block => 625,000 entries. 3. Entry size = 4 + 8 = 12 bytes, so entries per index block = floor(8192/12)=682. 4. Index blocks = ceil(625,000 / 682) = 917. Correct answer: 917.

Guided checkpoint

Given the following properties:

  • Data file: 10 million tuples, each tuple requires 512 bytes
  • Disk block size: 8192 bytes
  • Index entry: search key 4 bytes + pointer 8 bytes
  • Index entries do not span blocks

How many blocks are required to store this sparse index? (Give your answer as a single integer.)

03

Second-level sparse index size

Path of calculation: 1. First-level sparse index has 917 blocks. 2. Second-level sparse index needs one entry per first-level block => 917 entries. 3. 682 entries fit per block. 4. ceil(917 / 682) = 2 blocks. Correct answer: 2.

Guided checkpoint

Given the following properties:

  • Data file: 10 million tuples, each tuple requires 512 bytes
  • Disk block size: 8192 bytes
  • Index entry: search key 4 bytes + pointer 8 bytes
  • Index entries do not span blocks

How many blocks are required to store a second-level sparse index if the first-level index is also sparse?

Section 02

Extensible hashing after inserting key 1000 to Which of the following statements is true? (B vs B+ Trees)

01

Extensible hashing after inserting key 1000

Correct answer is Option B: the directory doubles first, then only the overflowing bucket is split (local depth == global depth at overflow).

Guided checkpoint

Consider this extensible hash table:

  • Bucket capacity: 4 records
  • Current global depth i = 1
  • Directory 0 -> bucket (local depth 1): 0010, 0101, 0011, 0110
  • Directory 1 -> bucket (local depth 1): 1010, 1110, 1001, 1011

Insert key 1000. Which resulting configuration is correct?

Initial extensible hash table before inserting key 1000

02

When inserting a key into a full block of an extensible hash table, if a bucket's local depth is less than global depth, the directory doubles in size.

Die richtige Antwort ist 'Falsch'. If local depth < global depth, you split only that bucket; doubling is needed only when local depth == global depth and split is required.

03

Which of the following statements is true? (B vs B+ Trees)

True, True, False, False.

Guided checkpoint

Mark each statement as True or False.

Section 03

A B+ tree always has a fixed height hh. Deleting a value from a B+ tree cannot change its height. to Grid file bucket count after split

01

A B+ tree always has a fixed height hh. Deleting a value from a B+ tree cannot change its height.

Die richtige Antwort ist 'Falsch'. Height can decrease after merges/underflow propagation.

02

Dense index size calculation

Path of calculation: 1. Dense index has one entry per tuple => 10,000,000 entries. 2. Entry size = 8 + 12 = 20 bytes. 3. Entries per block = floor(4096 / 20) = 204. 4. Blocks = ceil(10,000,000 / 204) = 49,020. Correct answer: 49020.

Guided checkpoint

Given the following properties of the data file, disk, and index structures:

  • Data file: 10 million tuples, each tuple requires 2048 bytes
  • Disk block size: 4096 bytes
  • Index: search key size 8 bytes, pointer size 12 bytes
  • Index entries do not span blocks

How many blocks are required to store this dense index? (single integer)

03

Grid file bucket count after split

Splitting one Page partition increases Page partitions from 9 to 10. Total buckets = 4 * 3 * 10 = 120.

Guided checkpoint

Given fact table Clicks(User, Session, Page, Position) with a grid file partitioned as:

  • User: 4 partitions
  • Session: 3 partitions
  • Page: 9 partitions

After ingesting more data, one partition of the Page dimension is split. How many buckets now exist in total?

Section 04

Hash index query support to B+ tree deletion: delete key 22

01

Hash index query support

True, False, False, False.

Guided checkpoint

Select the type of queries efficiently supported by a hash index on attribute aa.

02

In a highly selective query, only a few elements qualify under the selection; most elements are discarded.

Die richtige Antwort ist 'Wahr'.

Guided checkpoint

(Note: Selectivity refers to the property of the index or query.)

03

B+ tree deletion: delete key 22

Correct answer is Option C. After deleting 22, rebalancing yields root key 40 with internal nodes [16, 30] and [47, 55], and leaves [8,13] -> [16,20,29] -> [30,37] -> [40,43] -> [47,53] -> [55,59].

Guided checkpoint

Consider the B+ tree below with the following properties:

  • Each node (except root) contains 2k42 \le k \le 4 keys.
  • Inner nodes: keys in subtree below pointer pip_i are less than key kik_i; keys below pointer pi+1p_{i+1} are greater or equal than key kik_i.
  • Delete operation first tries to steal from a direct sibling (first right sibling, then left sibling). If stealing is not possible, nodes merge (first with right sibling, then left sibling).
  • Leaf pointers p1,,p4p_1, \dots, p_4 in leaves point to row IDs; pointer p5p_5 points to next leaf.
Initial B+ tree before deleting key 22

Which of the following choices represents the B+ tree after deletion of key 22?

Section 05

B+ tree insertion: insert key 43 to If a data table has one attribute with normal distribution, the quad-tree resulting from this data table will be balanced.

01

B+ tree insertion: insert key 43

Correct answer is Option A. Inserting 43 causes a split on the affected leaf, and the promoted separator to the root is 34 (not 42/43), yielding root [34, 49, 67] with leaves [26,31], [34,42,43], [49,54,59], [67,68,73].

Guided checkpoint

Consider the B+ tree below with the following properties:

  • Each node (except the root) contains 2k42 \le k \le 4 keys.
  • Inner nodes: keys in the subtree below pointer pip_i are less than key kik_i; keys below pointer pi+1p_{i+1} are greater or equal than key kik_i.
  • Insert operations may trigger node splits but no shifting of keys into neighboring leaves.
  • When a node is split, the middle key is moved to the parent node.
  • Pointers p1,,p4p_1, \dots, p_4 in leaves point to row IDs. Pointer p5p_5 points to the next leaf.
Initial B+ tree before inserting key 43

Which of the following choices represents the B+ tree after insertion of key 43?

02

Linear hashing adds an overflow bucket when the fill rate is exceeded during insertion.

Die richtige Antwort ist 'Falsch'.

03

If a data table has one attribute with normal distribution, the quad-tree resulting from this data table will be balanced.

False. The resulting quad-tree will be unbalanced because there will be more data points in the middle. Die richtige Antwort ist 'Falsch'.

Section 06

Query type classification to A sparse index has an entry for every row in the table and therefore needs less space than a dense index.

01

Query type classification

This query filters on only one dimension (PostalCode), requiring exploration of all Age values that have PostalCode = 10629. This makes it a partial-match query. Die richtige Antwort ist: Partial-Match Query.

Guided checkpoint

Consider relation Customer(Age, Gender, PostalCode, City, TotalSpent).

The following query:

SELECT *
FROM Customer
WHERE PostalCode = 10629

is an example of:

02

Partitioned hashing: buckets checked for partial match on a

For partial match on a, only 4 bits are fixed and 12 bits remain free. Number of buckets checked = 2^12 = 4096. Die richtige Antwort ist: 4096.

Guided checkpoint

Consider relation R(a, b, c, d) stored using partitioned hashing:

  • Total buckets: 65536 (16-bit hash function)
  • Bit allocation: 4 bits for a, 5 bits for b, 3 bits for c, 4 bits for d

How many buckets must be checked for a partial match query on a?

Example:

SELECT *
FROM R
WHERE a = 'y';

03

A sparse index has an entry for every row in the table and therefore needs less space than a dense index.

Die richtige Antwort ist 'Falsch'.

Section 07

kd-tree partitions

01

kd-tree partitions

Die richtige Antwort ist: Option D.

Guided checkpoint

Given the following kd-tree, choose the corresponding partitions.

Initial kd-tree for partition matching

Knowledge check

Turn understanding into recall.

The quiz now follows the same concepts in scored form. You can return to this lesson from the quiz whenever a gap appears.