Which statement correctly describes the uniqueness property of primary and secondary indexes in a database?
Think about the role of a primary key in a table.
A primary index is built on the primary key, which uniquely identifies each record, so it enforces uniqueness. Secondary indexes can be built on non-unique columns and do not enforce uniqueness.
Where are primary and secondary indexes typically stored in relation to the data in a database?
Consider how clustered and non-clustered indexes work.
Primary indexes are often clustered, meaning the data is physically sorted according to the primary key. Secondary indexes are non-clustered and store pointers to the actual data rows.
You have a table with millions of records and frequent queries filtering by a non-unique column. Which index type should you create to improve query speed without affecting data uniqueness?
Primary indexes require uniqueness; think about which index supports non-unique columns.
Primary indexes require unique columns. For non-unique columns, secondary indexes are used to speed up queries without enforcing uniqueness.
How does having a primary index compared to multiple secondary indexes affect the performance of inserting new records into a database table?
Consider how many indexes need updating when inserting a new row.
While primary indexes require maintaining sorted data, secondary indexes require updating multiple separate index structures, which can slow inserts more as the number of secondary indexes grows.
In a database system, if secondary indexes are not updated correctly after data changes, what kind of problem can occur when querying using those indexes?
Think about what happens if an index points to data that no longer exists or has changed.
If secondary indexes are not updated after data changes, they can point to wrong or missing rows, causing queries to return outdated or incorrect results.