Keys and Relationships
A primary key identifies a row. It is unique and never null, which is what makes a row addressable at all.
Prefer a key with no meaning, such as an auto-assigned id. Anything meaningful, an email, a title, a national number, eventually changes or turns out not to be unique.
A foreign key points at a row in another table. books.author_id holds the id of a row in authors.
That single idea is what makes the model relational. The author's name is stored once, in one row, and every book refers to it. Correct a spelling there and every book is correct, because there is only one copy of the fact.
Mark this lesson complete
Signed in, your progress follows you to every device.