Which of the following best describes a covering index in a database?
Think about how an index can help avoid reading the main table data.
A covering index includes all columns required by a query, so the database can answer the query using only the index, avoiding extra reads from the table.
Given a table Employees(id, name, department, salary) with a covering index on (department, salary), what will the query below return?
SELECT department, salary FROM Employees WHERE department = 'Sales';
Remember what columns the covering index includes and what the query requests.
The query requests only columns in the covering index (department, salary), so the database can use the index to return matching rows without accessing the full table.
Which SQL statement correctly creates a covering index on the Orders table to cover the columns customer_id and order_date?
Some SQL dialects support INCLUDE to add columns to the index without sorting on them.
Option D creates an index on customer_id and includes order_date as non-key columns, making it a covering index. Option D creates a composite index but may not cover all queries if order_date is not a key column.
How does a covering index improve query performance compared to a regular index?
Think about how indexes help the database find data faster.
A covering index contains all columns needed by the query, so the database can answer the query using only the index, reducing disk reads and improving speed.
Given a covering index on (product_id, price) for the Sales table, why does the query below not use the covering index?
SELECT product_id, price, sale_date FROM Sales WHERE product_id = 101;
Check which columns the index covers and which columns the query requests.
The query requests sale_date which is not part of the covering index, so the database must access the main table data, preventing the index from fully covering the query.