Two books in a York school library have the same title. Which one did you borrow?
You borrowed a book called The Island from your school library in York. The librarian finds two books with that title. When you bring yours back, how can the computer tell which book you borrowed?
A database is an organised collection of data. In the Books table, each row is a record and each column is a field. Book ID is stored as an integer, a whole number, and Title is stored as text. Spot the two rows with the title The Island.
Search for The Island and you get two matches. Search for Book ID one hundred and five and you get one. Every book record has a different Book ID, so you can choose that field as the primary key. A primary key uniquely identifies each record in its table.
You're choosing the key for the Books table. Two records share the title The Island, but each record has its own Book ID. Which field should be the primary key? Pick the best answer.
Start at loan seventy-three. Its Book ID is one hundred and five. Follow the arrow to the book with that ID. Book ID in Loans is a foreign key because it refers to the primary key in Books. A relational database stores data in tables linked by keys.
Loan seventy-three stores Book ID one hundred and five. Loan seventy-four stores the same Book ID. Both values match the same Books record, The Island. You can still tell the loans apart: Loan ID is the primary key in Loans, so each loan has a different Loan ID.
Two new rows have Loan IDs eighty-one and eighty-two. Each row has Book ID one hundred and six. What does that tell you about the loans and the book? Pick one answer.
In Books, Book ID identifies the book record. One hundred and five appears once because the primary key must be unique. In Loans, Book ID refers to that book, so one hundred and five can appear on both loan rows. It's a mistake to demand unique Book IDs in Loans.
Copying a book's title into every loan adds redundancy, or repeated data. If you correct the title but miss a copy, the titles disagree. That's inconsistency. With linked tables, you store the title once per book. Correct it in Books and every linked loan points to the corrected title.