Linux Format

Indexes and keys

-

The real point of using a database over a spreadshee­t is its ability to index and retrieve your data in any way you want to present it. The way this works is the database indexes fields in particular tables and is then able to retrieve individual records according to a unique ID value that’s been assigned to each record.

Primary keys are a unique value that databases use to identify one record from another. For example, it defines that two John Smiths that live in Coventry are not the same human being. Similarly, it ensures that two books with unique IDs can still be attributed to the same author (with their unique ID) thanks to an additional field called a foreign key.

A foreign key will often have the same name as its matching primary key in another table. But unlike a primary key field it makes duplicate values possible because its entire purpose is to link multiple records in one table to a single primary key in another.

Finally, keys used for indexing don’t always have to be numerical ID numbers. As you’ll see later on in this tutorial, it’s possible to use text fields in lookup tables to ensure that data inserted into LibreOffic­eBase is valid and not duplicated due to typos.

Newspapers in English

Newspapers from Australia