Docsity

Indexes Practice Exam, Exams of Technology

Toggle sidebar
bg1
Indexes Practice Exam
Question 1. What is the primary purpose of an index in a database system?
A) Increase storage space
B) Minimize disk I/O during data retrieval
C) Ensure data security
D) Compress data
Answer: B
Explanation: Indexes reduce the number of disk accesses needed to find data, making retrieval faster.
Question 2. In indexing terminology, what is a search key?
A) The physical address of a record
B) The column(s) used for index lookup
C) The entire database table
D) The size of an index
Answer: B
Explanation: The search key is the column or columns in a table on which the index is created and used
for searching.
Question 3. What does a typical index record contain?
A) Only a pointer
B) Only a key value
C) Key value and pointer to data
D) Table metadata
Answer: C
Explanation: Each index entry consists of a search key value and a pointer to the corresponding data
block or record.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52

Partial preview of the text

Download Indexes Practice Exam and more Exams Technology in PDF only on Docsity!

Question 1. What is the primary purpose of an index in a database system? A) Increase storage space B) Minimize disk I/O during data retrieval C) Ensure data security D) Compress data Answer: B Explanation: Indexes reduce the number of disk accesses needed to find data, making retrieval faster. Question 2. In indexing terminology, what is a search key? A) The physical address of a record B) The column(s) used for index lookup C) The entire database table D) The size of an index Answer: B Explanation: The search key is the column or columns in a table on which the index is created and used for searching. Question 3. What does a typical index record contain? A) Only a pointer B) Only a key value C) Key value and pointer to data D) Table metadata Answer: C Explanation: Each index entry consists of a search key value and a pointer to the corresponding data block or record.

Question 4. Which search method scans every record sequentially? A) Binary search B) Hash search C) Linear search D) B-Tree traversal Answer: C Explanation: Linear search examines each record in sequence, making it less efficient than indexed searches. Question 5. What is a main advantage of binary search over linear search in indexes? A) Less memory usage B) Faster search time C) More complex code D) Random data access Answer: B Explanation: Binary search divides the search space in half each time, making it much faster than linear search. Question 6. In a B-Tree index, what is the role of the root node? A) Always stores data B) Contains the highest key values C) Serves as the entry point for all searches D) Connects directly to leaf nodes only Answer: C Explanation: The root node is the starting point for traversing the tree during searches.

Question 10. What is the defining feature of a clustered index? A) Always uses a B-Tree B) Determines the physical order of table data C) Requires a hash function D) Is stored separately from table data Answer: B Explanation: In a clustered index, the order of the index matches the physical order of rows in the data file. Question 11. In a non-clustered index, how is data accessed? A) Directly from the index B) Through pointers from the index to table rows C) By scanning all records D) Using hash buckets Answer: B Explanation: Non-clustered indexes have pointers that refer back to the actual table data. Question 12. What type of index is created on a table’s primary key? A) Secondary index B) Bitmap index C) Primary index D) Hash index Answer: C Explanation: A primary index is defined using the primary key of a table.

Question 13. Which index type is created on non-key columns? A) Sparse index B) Clustered index C) Secondary index D) Unique index Answer: C Explanation: Secondary indexes are created on columns that are not the primary key. Question 14. What is a dense index? A) Only indexes some data blocks B) Contains an entry for every record C) Is always sparse D) Uses hash buckets Answer: B Explanation: A dense index has an entry for every search key value, covering all records. Question 15. How does a sparse index differ from a dense index? A) Indexes all rows B) Only includes entries for some records, usually one per block C) Always uses bitmaps D) Is required for all tables Answer: B Explanation: Sparse indexes have fewer entries, typically one per block, not every record. Question 16. What is the main advantage of multilevel indexing?

A) CREATE UNIQUE INDEX

B) CREATE INDEX

C) CREATE CLUSTERED INDEX

D) DROP INDEX

Answer: B Explanation: CREATE INDEX creates a standard (not necessarily unique) index. Question 20. Which SQL statement removes an index? A) DELETE INDEX B) REMOVE INDEX C) DROP INDEX D) ALTER INDEX Answer: C Explanation: DROP INDEX is used to delete an existing index. Question 21. How can you rebuild or reorganize a fragmented index? A) ALTER INDEX B) CREATE INDEX C) TRUNCATE INDEX D) SELECT INDEX Answer: A Explanation: ALTER INDEX can be used to reorganize or rebuild fragmented indexes, improving performance. Question 22. Which constraint automatically creates an index in most RDBMS?

A) FOREIGN KEY

B) DEFAULT

C) UNIQUE

D) CHECK

Answer: C Explanation: A UNIQUE constraint typically creates an index to enforce uniqueness. Question 23. What SQL command shows existing indexes on a table in MySQL? A) SHOW TABLES B) SHOW INDEXES C) DESCRIBE TABLE D) SELECT INDEX Answer: B Explanation: SHOW INDEXES (or SHOW INDEX FROM table) lists all indexes for a table. Question 24. Why is “high selectivity” important for index selection? A) It means few distinct values B) It indicates many rows share the same value C) It means many distinct values, which makes the index more efficient D) It reduces storage size Answer: C Explanation: High selectivity (many unique values) makes indexes more beneficial for query performance. Question 25. What is a covering index?

Question 28. What is index fragmentation? A) Duplicate indexes B) Scattering of index data across non-contiguous disk blocks C) Indexes on multiple columns D) Indexes without primary keys Answer: B Explanation: Fragmentation happens when index pages are scattered, slowing down read operations. Question 29. What is a filtered index? A) Index on all table rows B) Index on a subset of table rows matching a condition C) Index with only pointers D) Deprecated index type Answer: B Explanation: Filtered indexes (partial indexes) only cover rows that meet a specific condition (e.g., WHERE status = 'Active'). Question 30. Which index type is most suitable for full-text searches? A) B-Tree index B) Bitmap index C) Full-text index D) Hash index Answer: C Explanation: Full-text indexes are optimized for searching large text fields for keywords or phrases.

Question 31. What is the main benefit of a columnstore index in data warehousing? A) Slower writes B) Faster analytical queries by organizing data by columns C) More disk usage D) Less readable data Answer: B Explanation: Columnstore indexes allow for faster aggregation and scanning in analytics workloads by storing data column-wise. Question 32. What is a function-based index? A) Index on raw columns only B) Index on the result of a function or expression C) Index without any keys D) Only for numeric columns Answer: B Explanation: A function-based index is built on the result of a function or expression (e.g., UPPER(name)). Question 33. Which type of index is most affected by frequent updates and deletes? A) Bitmap index B) B-Tree index C) Hash index D) Clustered index Answer: A Explanation: Bitmap indexes can become inefficient and fragmented with frequent updates or deletes.

A) Data is deleted B) Table is dropped C) Only the index structure is removed D) All keys are reset Answer: C Explanation: DROP INDEX removes the index, but not the data; queries may become slower as a result. Question 38. In which scenario is a sparse index preferred over a dense index? A) When the data file is small B) When there are few index entries per block C) When every search key is unique D) For text search Answer: B Explanation: Sparse indexes are efficient for large, ordered files with fewer index entries per block. Question 39. What is a pointer in the context of an index? A) Value of the row B) Reference to the location of the data record C) Name of the column D) Key value Answer: B Explanation: A pointer in an index points to the physical location of the corresponding data record. Question 40. Which index type maintains a physical order of rows in the table? A) Non-clustered index

B) Clustered index C) Hash index D) Bitmap index Answer: B Explanation: Clustered indexes define the physical order of data rows on disk. Question 41. What is a secondary index? A) Index on the primary key B) Index on any non-primary key column C) Always unique D) Only for numeric data Answer: B Explanation: Secondary indexes are created on columns other than the primary key. Question 42. What does the “index of indexes” refer to? A) Composite index B) Multilevel index C) Hash index D) Covering index Answer: B Explanation: Multilevel indexing involves creating indexes on the search keys of lower-level indexes. Question 43. What kind of query benefits most from a covering index? A) One that selects all columns B) One that selects only indexed columns

C) Contains the key value D) Represents a hash bucket Answer: B Explanation: In B-Tree indexes, pointers link to child nodes or directly to data records at leaf level. Question 47. What is the maximum number of indexes you can create on a table? A) Unlimited B) Database-specific limit C) Only one D) None Answer: B Explanation: The maximum number of indexes is determined by the specific database system. Question 48. Which index type is best for retrieving records with a specific value? A) Hash index B) Bitmap index C) B-Tree index D) Multilevel index Answer: A Explanation: Hash indexes are highly efficient for equality searches (e.g., WHERE id = 5). Question 49. Which structure is used to implement a bitmap index? A) Linked list B) Array of bits C) B-Tree

D) Hash table Answer: B Explanation: Bitmap indexes use bit arrays to represent the presence or absence of values. Question 50. Which SQL command can be used to inspect index fragmentation in SQL Server? A) SHOW INDEX B) DBCC SHOWCONTIG C) SELECT INDEX D) ALTER INDEX Answer: B Explanation: DBCC SHOWCONTIG displays information about index fragmentation in SQL Server. Question 51. What is the main disadvantage of too many indexes on a table? A) Slows down SELECT queries B) Increases update and insert overhead C) Reduces table size D) Makes data more secure Answer: B Explanation: Each index must be updated on INSERT, UPDATE, and DELETE, increasing write overhead. Question 52. Which index structure is typically used for OLAP systems? A) Rowstore B) Columnstore C) Hash index D) Dense index

Explanation: Without a clustered index, table rows lose physical ordering and the table becomes a heap. Question 56. When is a composite index most useful? A) For single-column queries B) For queries filtering on multiple columns in the defined order C) On text columns only D) For counting rows Answer: B Explanation: Composite indexes are most effective when queries filter on the indexed columns in left-to- right order. Question 57. Which of the following is NOT a benefit of indexing? A) Faster data retrieval B) Reduced disk storage C) Improved query performance D) Faster sorting Answer: B Explanation: Indexes actually require additional storage space. Question 58. In which scenario would a function-based index be particularly useful? A) When filtering on computed expressions B) For direct column filtering C) For primary key lookups D) For sorting only Answer: A

Explanation: Function-based indexes speed up searches involving computed values (e.g., WHERE UPPER(name) = 'SMITH'). Question 59. How does an index help with ORDER BY queries? A) Sorts data automatically B) Provides data in indexed order, reducing sort operations C) Removes duplicates D) Compresses data Answer: B Explanation: If the ORDER BY column(s) are indexed, the database can retrieve data already sorted. Question 60. Which index type is typically recommended for fact tables in star schemas? A) Hash index B) Bitmap index C) Non-clustered B-Tree index D) Unique index Answer: B Explanation: Bitmap indexes are well-suited for fact tables with low-cardinality columns in star schemas. Question 61. What is the result of creating a UNIQUE index? A) Duplicate values are allowed B) Enforces uniqueness of values in the indexed column(s) C) Table size increases D) All queries are faster Answer: B