12. Secondary key

DEFINITION:

A secondary key is made on a field that you would like to be indexed for faster searches. A table can have more than one secondary key

 

The main purpose of a database is to store and search for data. When databases become large, possibly with hundreds of thousands of records, they can take a while to search.

A database can be set up so that it can be searched more efficiently. Fields that are likely to be indexsearched upon can be indexed for faster searching.

For example, imagine a customer database. When a customer rings up with an account enquiry, the most likely thing that they will be asked for is either their surname or their account number. These details will be used to search for their account information. Thus, these fields would be an ideal choice to set up as an indexed field.

It is very unlikely that they would be initially asked for their first name or the town in which they live, so it wouldn't really be much use setting these up to be searched more quickly.

When you set up a database table, you can set the field to be 'indexed'.

Think of it like an index in the back of a book - it helps you find the information you want in a book much faster, and indexing a field in a database works pretty much in the same way.

 

challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Secondary key