Welcome @name to the Bridge of Knowledge - a stone walkway that connects two wings of the Great Library. On one side stands the shelf of books, on the other the shelf of author descriptions. A book scroll alone will not tell you who its creator was - you must cross the bridge of cross-references.
In our Library we do not keep everything on one scroll. An author's name is not repeated next to each of their books - that would be chaos and a waste of papyrus. Instead we have a separate
autorzy shelf, and each book carries only a cross-reference to it.| ksiazki.id | tytul | autor_id | |------------|-------|----------| | 1 | Iliada | 3 | | 2 | Odyseja | 3 |
| autorzy.id | imie | nazwisko | |------------|------|----------| | 3 | Homer | z Jonii |
The
ksiazki.autor_id column is a foreign key. It points to a row in another shelf through its primary key: autor_id in the ksiazki table points to id in the autorzy table.This is exactly how a whole relational database works - shelves linked by cross-references:
ksiazki.autor_id → autorzy.idksiazki.kategoria_id → kategorie.idwypozyczenia.ksiazka_id → ksiazki.idwypozyczenia.czytelnik_id → czytelnicy.idTo see a book's title and the author's surname in one result, we must learn to walk across these cross-references. We call this art JOIN - joining tables. Let us step onto the bridge, @name!