As databases grow larger, finding data quickly becomes a challenge. In IB Computer Science, this problem is addressed using indexes. Students are expected to understand what an index is, how it improves performance, and the trade-offs involved.
Indexes are not about storing more data — they are about finding data faster.
What Is a Database Index?
A database index is a data structure that:
- Speeds up data retrieval
- Allows the database to locate records efficiently
- Reduces the need to scan entire tables
An index works in a similar way to:
- An index in a textbook
Instead of reading every page, the index points directly to the correct location.
Why Indexes Are Needed
Without an index:
- The database must scan every record
- Searches become slower as tables grow
- Performance degrades significantly
This type of search is known as a full table scan.
Indexes allow the database to:
- Jump directly to relevant records
- Reduce the number of comparisons
- Return results much faster
In IB terms, indexes improve efficiency, not accuracy.
How Indexes Work (Conceptually)
Conceptually, an index:
- Stores values from one or more fields
