0
0
MySQLquery~5 mins

Creating indexes in MySQL - Quick Revision & Summary

Choose your learning style9 modes available
Recall & Review
beginner
What is an index in a database?
An index is like a shortcut in a book. It helps the database find data faster without looking at every row.
Click to reveal answer
beginner
How do you create a simple index on a column named 'name' in MySQL?
Use the command: CREATE INDEX idx_name ON table_name(name); This makes searching by 'name' faster.
Click to reveal answer
intermediate
What is the difference between a UNIQUE index and a regular index?
A UNIQUE index makes sure no two rows have the same value in the indexed column, while a regular index just speeds up searches.
Click to reveal answer
intermediate
Why should you not create too many indexes on a table?
Too many indexes slow down data changes like INSERT, UPDATE, DELETE because the database must update all indexes too.
Click to reveal answer
intermediate
What is a composite index?
A composite index is an index on multiple columns together. It helps speed up searches that use those columns combined.
Click to reveal answer
Which command creates an index on the 'email' column in MySQL?
ACREATE INDEX idx_email ON users(email);
BCREATE TABLE idx_email ON users(email);
CINSERT INDEX idx_email ON users(email);
DALTER TABLE users ADD COLUMN idx_email(email);
What does a UNIQUE index ensure?
ANo duplicate values in the indexed column
BFaster data insertion
CAllows NULL values only
DDeletes duplicate rows automatically
Which is a downside of having many indexes on a table?
AIndexes automatically fix data errors
BSlower data retrieval
CMore disk space saved
DSlower data modification operations
What is a composite index?
AAn index on a single column
BAn index on multiple columns together
CAn index that stores data in compressed form
DAn index that automatically updates
Which of these is NOT a valid reason to create an index?
ASpeed up search queries
BEnforce uniqueness of data
CMake data insertion faster
DImprove join performance
Explain what an index is and why it is useful in a database.
Think about how you find a topic quickly in a book.
You got /3 concepts.
    Describe how to create a simple index in MySQL and mention one important consideration when using indexes.
    Remember the command and why too many indexes can be bad.
    You got /3 concepts.