Sample questions
Question 1Easy
Which index type determines the physical order of rows in the table?
- Bitmap index
- Secondary dense index
- Clustered index
- Non-clustered index
Answer: C. Clustered index
Explanation
Rows are stored in clustered-index order, which is why a table can have only one clustered index.
Step-by-step solution
- A clustered index stores (or keeps) rows in index-key order.
- So it decides the physical row order.
- Hence only one per table.
Why the other options are wrong
- A. Bitmap indexes are separate bit arrays.
- B. Secondary indexes do not change row order.
- D. Non-clustered indexes point to rows wherever they are.
Tip: Clustered = physical order.
Question 2Easy
The column or columns on which an index is built are called the:
- Search key
- Clustered table
- Partition
- Foreign key
Answer: A. Search key
Explanation
The search key need not be a primary key or even unique; it is simply the value the index is organised on.
Step-by-step solution
- An index is organised on the values of one or more columns.
- These columns are called the search key.
- It need not be unique or the primary key.
Why the other options are wrong
- B. Clustered describes how the table is stored.
- C. Partitioning splits a table across storage.
- D. A foreign key is a referential constraint.
Tip: Search key = whatever the index is built on.
Question 3Easy
A secondary index (on a non-ordering field) must be:
- Sparse
- Dense
- Clustered
- Hash-based only
Answer: B. Dense
Explanation
The file is not sorted on that field, so every value (or record) needs its own index entry.
Step-by-step solution
- The file is not sorted on the secondary field.
- Records with nearby values can be in any block.
- So every record (value) needs its own index entry: dense.
Why the other options are wrong
- A. Sparse indexes need the file ordered on that field.
- C. A table can be clustered on only one field, usually not this one.
- D. Secondary indexes are often B+ trees.
Tip: Secondary index = always dense.
Question 4Easy
- Entries for only some search-key values, e.g. one per block
- An entry for every record
- Entries sorted in random order
- Only the primary key column
Answer: A. Entries for only some search-key values, e.g. one per block
Explanation
Sparse indexes need the data file to be sorted on the key; you find the nearest smaller entry and scan the block.
Step-by-step solution
- A sparse index has entries for only some key values.
- Usually one entry per data block (the block's first key).
- The file must be sorted on that key.
Why the other options are wrong
- B. An entry for every record is a dense index.
- C. Index entries are always sorted.
- D. Sparse indexes are not restricted to the primary key.
Tip: Sparse = one entry per block; dense = one entry per record.
Question 5Medium
A dense index on a file of 50,000 records stores 100 entries per block. Binary search on the index takes how many block accesses, plus one to read the data block?
- 7 + 1 = 8
- 9 + 1 = 10
- 500 + 1 = 501
- 16 + 1 = 17
Answer: B. 9 + 1 = 10
Explanation
The index has 50,000 / 100 = 500 blocks; binary search needs ⌈log2 500⌉ = 9 accesses, then 1 more for the data block.
Step-by-step solution
- Index blocks = 50,000 / 100
= 500.
- Binary search:
ceil(log2 500) = 9
(2^9 = 512).
- Plus one data block: 10.
Why the other options are wrong
- A. 2^7 = 128 is less than 500 blocks.
- C. 501 is a linear scan of the index.
- D. 16 is log2 of the record count, not the index blocks.
Tip: Index blocks first, then ceil(log2), then + 1.
Question 6Medium
An index that contains every column a query needs, so the table itself is never read, is called a:
- Partial index
- Covering index
- Sparse index
- Clustered index
Answer: B. Covering index
Explanation
With a covering index the query is answered with an index-only scan.
Step-by-step solution
- The query needs certain columns.
- If the index contains all of them, the DBMS answers from the index alone.
- Such an index is a covering index (index-only scan).
Why the other options are wrong
- A. A partial index covers only rows matching a condition.
- C. Sparse refers to having entries for only some keys.
- D. Clustered refers to physical row order.
Tip: All needed columns in the index = covering.
Question 7Medium
The search cost of a B+ tree with N keys and fan-out f is about:
- N/f node accesses
- log_f(N) node accesses
- f × N node accesses
- A constant number regardless of N
Answer: B. log_f(N) node accesses
Explanation
Each level divides the search space by the fan-out, so height grows logarithmically with base f.
Step-by-step solution
- Each node has up to f children.
- Each level down narrows the search by a factor of f.
- After h levels f^h covers N keys, so h is about log_f(N) node reads.
Why the other options are wrong
- A. N/f would be a scan of leaf blocks, not a tree search.
- C. This is more than a full scan.
- D. Height grows with N, slowly.
Tip: With fan-out 100, three levels cover about a million keys.
Question 8Medium
A composite index on (last_name, first_name) can efficiently answer which query?
- WHERE last_name = 'Rao'
- WHERE first_name LIKE '%a'
- WHERE first_name = 'Asha'
- ORDER BY first_name only
Answer: A. WHERE last_name = 'Rao'
Explanation
A composite B+ tree index is ordered by the leading column first, so it helps queries that constrain a prefix of its columns.
Step-by-step solution
- A composite index is sorted by last_name, then first_name.
- A search on last_name uses the sorted prefix.
- first_name alone is scattered across the index.
Why the other options are wrong
- B. A leading wildcard prevents using any sort order.
- C. first_name is not the leading column.
- D. Sorting by the second column alone does not follow the index order.
Tip: Composite index = leftmost prefix only.
Question 9Hard
A sorted data file has 40,000 records, 20 per block. A sparse primary index has one entry per data block, with 50 entries per index block. How many block accesses does a lookup need using binary search on the index plus one data-block read?
- 7
- 9
- 40
- 11
Answer: A. 7
Explanation
Data blocks: 2000.
Index blocks: ⌈2000/50⌉ = 40.
Binary search: ⌈log2 40⌉ = 6, plus 1 data block = 7.
Step-by-step solution
- Data blocks = 40,000 / 20 = 2,000, so 2,000 index entries.
- Index blocks = 2,000 / 50 = 40.
- ceil(log2 40) = 6, plus 1 data block = 7.
Why the other options are wrong
- B. 9 uses the wrong number of index blocks.
- C. 40 is a linear scan of the index blocks.
- D. 11 is about log2 of the 2,000 data blocks, as if there were no index.
Tip: Sparse: entries = data blocks.
Question 10Hard
A B+ tree leaf node is a 1024-byte block holding (key, record pointer) pairs plus one 8-byte pointer to the next leaf. Keys are 10 bytes and record pointers 6 bytes. How many keys fit in a leaf?
- 64
- 101
- 63
- 62
Answer: C. 63
Explanation
16n + 8 ≤ 1024 gives n ≤ 63.50, so n = 63.
Step-by-step solution
- Each (key, record pointer) pair is 10 + 6 = 16 bytes.
- 16k + 8 <= 1024, so k <= 63.5.
- k = 63.
Why the other options are wrong
- A. 64 pairs take 1024 bytes, leaving no room for the next-leaf pointer.
- B. 101 = 1024 / 10 ignores pointers.
- D. 62 fits but is not the maximum.
Tip: Leaf: k(K + Pr) + Pnext <= B.
Practise all 39 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →