Which of the following best explains why adding an index to a table column can improve query performance?
Think about how a phone book helps you find a name faster without reading every page.
Indexes act like a quick lookup guide, allowing the database to find rows without scanning the whole table.
Consider a table with a column storing dates. Which data type choice will generally use less storage and improve query speed?
Think about storing dates in a format the database understands natively.
DATE type uses fixed, compact storage and allows efficient date operations, unlike text types.
Which SQL statement correctly defines a primary key on the 'id' column during table creation?
CREATE TABLE users ( id INT, name VARCHAR(100), PRIMARY KEY (id) );
Primary key syntax requires parentheses around column names or inline declaration.
Option D correctly declares 'id' as primary key inline. Option D and C have syntax errors. Option D uses wrong column.
Which scenario best explains when denormalizing a table can improve performance?
Think about how joining many tables can slow down queries.
Denormalization duplicates some data to avoid costly joins, improving read performance at the cost of storage and update complexity.
A query filtering on a 'status' column is very slow on a large table. The 'status' column has only three possible values. What is the most likely cause?
Indexes on columns with few distinct values may not be used by the database.
Low cardinality indexes (few unique values) are often ignored by the optimizer because scanning is cheaper than using the index.