Clustered Indexes Quiz

Explore the key concepts, advantages, and common pitfalls of clustered indexes with this focused quiz. Strengthen your understanding of how clustered indexes shape data organization, query performance, and best practices in relational databases.

  1. Definition of Clustered Index

    Which statement best describes a clustered index in a relational database?

    1. A clustered index is solely used for full-text search operations.
    2. A clustered index always allows multiple instances per table.
    3. A clustered index creates a separate copy of the table's data for fast searches.
    4. A clustered index determines the physical order of data rows in a table.

    Explanation: A clustered index determines the actual physical storage order of the data within the table, making access to indexed data efficient. Unlike clustered indexes, nonclustered indexes do not affect how data rows are stored but instead keep a logical order. There can only be one clustered index per table, so the third option is incorrect. Clustered indexes are not designed exclusively for full-text searches; they are fundamental for various types of lookups.

  2. Uniqueness of Clustered Index per Table

    Why can a table have only one clustered index?

    1. Because each clustered index disables nonclustered indexes.
    2. Because clustered indexes duplicate all data in the table by default.
    3. Because a table's rows can be sorted in only one physical order.
    4. Because only unique data types support clustered indexes.

    Explanation: A table can have only one clustered index because the clustered index defines the one and only physical order of data on disk. Creating additional clustered indexes would require multiple concurrent physical organizations, which is not possible for a single data set. The second option is false; clustered indexes do not duplicate data. The third option is inaccurate, as nonclustered indexes can exist alongside a clustered index. The fourth option is irrelevant; data types do not affect the ability to define a clustered index.

  3. Primary Key and Clustered Index Relationship

    What is the default relationship between a primary key and a clustered index in most relational databases?

    1. A primary key constraint removes any existing clustered index by default.
    2. A primary key constraint never creates a clustered index and always creates a nonclustered index.
    3. A primary key constraint automatically creates a clustered index if none exists.
    4. A primary key constraint must be defined on a nonclustered index.

    Explanation: Most systems automatically create a clustered index on the primary key column if a table does not already have a clustered index. Existing clustered indexes are not removed but would prevent another from being added, so the second answer is wrong. The third choice is incorrect because a nonclustered index is created only if a clustered index already exists. The last option is false since a primary key does not have to be associated with a nonclustered index.

  4. Performance Impact of Clustered Indexes

    When can a clustered index significantly improve query performance?

    1. When all queries are random updates to non-indexed columns.
    2. When queries frequently search for ranges of values in the index key column.
    3. When the table contains only duplicate rows.
    4. When all queries use wildcards at the start of the search term.

    Explanation: Clustered indexes improve performance in range queries, as the data is stored in order of the index key, making it efficient to scan contiguous records. Random updates to non-indexed columns do not benefit from the index as it's not involved. A table of duplicates does not exploit the main advantage of clustered indexes. Queries starting with wildcards bypass ordered lookups and lessen the benefits of indexing.

  5. Choosing a Clustered Index Key

    Which characteristic is most important when selecting a column for a clustered index?

    1. The column should be the widest field in the table.
    2. The column should rarely appear in search queries.
    3. The column should have values that are almost always null.
    4. The column should have values that are unique and unlikely to change.

    Explanation: A good clustered index key should be unique and stable, as changes require physical data reorganization. Wide columns increase index size and decrease efficiency, so that choice is incorrect. Columns often searched are preferred index candidates; rarely searched columns are unsuitable. Columns that are mostly null add little value as clustered index keys.

  6. Effect on Data Insertion

    How can a poorly chosen clustered index key negatively affect data insertion?

    1. It forces all values in the column to become uppercase.
    2. A poor key choice will prevent insertions from happening.
    3. It always requires the table to be locked for each insert.
    4. Frequent changes to the clustered key can cause page splits and fragmentation.

    Explanation: If the clustered key changes often or is not sequential, insert operations can cause page splits and data fragmentation, which degrade performance. A poor key does not prevent inserts nor require every insert to lock the whole table. Clustered indexes do not affect data case, and uppercase enforcement is not related to indexing.

  7. Clustered Index vs. Nonclustered Index

    What is a key difference between a clustered index and a nonclustered index?

    1. Nonclustered indexes can only be created on text columns.
    2. Clustered indexes do not support search operations.
    3. A clustered index always increases storage size more than any nonclustered index.
    4. A clustered index dictates data storage order, while a nonclustered index does not.

    Explanation: The clustered index determines how data is physically stored, making its key particularly important. Nonclustered indexes provide a separate logical structure and do not affect data order. Nonclustered indexes are not limited to text columns, and both types of indexes support search operations, so those options are incorrect.

  8. Limitation on Number of Clustered Indexes

    What is the maximum number of clustered indexes allowed per table in relational databases?

    1. Only one clustered index is allowed per table.
    2. A table can have as many clustered indexes as it has columns.
    3. Two clustered indexes per table are allowed if columns are unique.
    4. The number of clustered indexes is unlimited for small tables.

    Explanation: A core property of clustered indexes is that only one can exist per table since they define the physical data layout. Multiple clustered indexes would conflict with each other, so the other choices are false. The uniqueness of columns does not affect this rule, nor do table size or column count.

  9. Clustered Index and Table Scans

    How does a clustered index reduce the need for full table scans?

    1. By automatically removing all non-indexed columns.
    2. By storing rows in the indexed column order, making targeted lookups faster.
    3. By sorting only the query result set, not the underlying data.
    4. By increasing the number of duplicate records in a table.

    Explanation: Clustered indexes arrange data rows physically by key order, letting the database quickly find or retrieve data without scanning the entire table. Increasing duplicates does not improve search efficiency and is not an indexing function. Clustered indexing does not remove columns. The result set can be sorted, but the key feature is the underlying data order, not merely result sorting.

  10. Composite Clustered Index Key

    What is a composite clustered index key?

    1. A clustered index with both a unique and a non-unique part.
    2. A clustered index built using two or more columns as the key.
    3. A nonclustered index that references multiple tables.
    4. A clustered index automatically created without user input.

    Explanation: A composite clustered index key uses several columns to define the ordering and uniqueness of entries. There is no such thing as a unique and non-unique part within a single composite key. Nonclustered indexes can reference multiple columns but not multiple tables within one index. Clustered indexes can be created by default, but a composite index specifically refers to multiple columns.

  11. Altering Clustered Index Key

    What is a likely effect of changing a clustered index to use a different column?

    1. Nonclustered indexes are automatically removed from the table.
    2. The physical order of all rows in the table will be reorganized according to the new key.
    3. The table will prevent further indexing operations.
    4. Only new records will be affected, while existing data is left unchanged.

    Explanation: Changing the clustered index causes the table's physical data order to be rebuilt around the new index key, a process called reorganization. Existing records are not left untouched—they are reordered. Nonclustered indexes remain but may need updating. Indexing is not blocked by this change.

  12. Clustered Index Key Size

    Why should the clustered index key be as small as practical?

    1. Small keys prevent the use of composite indexes.
    2. A smaller key requires less storage space and enables more efficient searches.
    3. Small keys can only be used on date columns.
    4. A smaller key makes full table scans slower.

    Explanation: Smaller clustered keys reduce index size and improve I/O performance, making searches and joins faster. Small keys do not negatively affect table scans, nor do they prevent the use of composite keys. There are no restrictions that limit small keys only to date columns.

  13. Clustered Index Maintenance

    Which maintenance operation is especially important for tables with clustered indexes that experience frequent inserts and deletes?

    1. Converting all clustered indexes to nonclustered indexes.
    2. Regular index defragmentation or rebuilding.
    3. Truncating the entire table daily.
    4. Disabling the clustered index before every query.

    Explanation: Frequent inserts and deletes can fragment data pages organized by a clustered index, making regular index maintenance crucial for performance. Truncating deletes all data and is generally not a solution. Converting index types is unnecessary and disruptive. Disabling an index before every query negates its purpose.

  14. Unique Constraints and Clustered Indexes

    How does a unique constraint on the clustered index key column affect the table?

    1. It prevents any indexes from being created on the table.
    2. It makes the nonclustered indexes unique.
    3. It allows duplicate values in the clustered key if they appear in noncontiguous rows.
    4. It guarantees that no two rows have the same value in the clustered index key column.

    Explanation: A unique constraint on a clustered index ensures every value in the key column is distinct, preventing duplicates. The second statement is false as uniqueness applies regardless of row contiguity. A unique constraint does not prevent index creation, nor does it enforce uniqueness on nonclustered indexes.

  15. Dropping a Clustered Index

    What effect does dropping a clustered index have on the underlying table?

    1. All nonclustered indexes are also dropped.
    2. The table's data is left unordered and becomes a heap.
    3. Existing primary key constraints are removed.
    4. The table is automatically deleted from the database.

    Explanation: Dropping a clustered index converts the table into a heap, where data has no defined physical order. The table is not deleted, and nonclustered indexes remain, though they may use row identifiers instead. Primary key constraints are not removed by dropping the index unless they were implemented via the dropped clustered index.

  16. Covering Indexed Queries with Clustered Index

    When can a clustered index itself cover a query without referencing other columns?

    1. When the query requests all columns except the indexed key column.
    2. When the query involves only aggregated values not present in the table.
    3. When the query only requests columns included in the clustered index key.
    4. When the query uses columns from non-indexed tables.

    Explanation: If a query's select columns are fully included in the clustered index key, the clustered index covers the query, making lookups direct and efficient. Using non-indexed tables or requesting other columns requires additional data access. Aggregated columns not found in the table cannot be covered, and queries needing excluded columns also are not covered.