What is a primary key?
Options
- The first column of every table that is created in a database
- A column (or columns) that uniquely identifies each row, never NULL (Correct option)
- The password that is used to protect access to the database
- The most important table of the whole schema of the database
Answer
A column (or set of columns) that uniquely identifies each row and can never be NULL
Why
Each row needs a unique ID so you can point to exactly that row: update it, delete it, or reference it from another table.
Typical primary keys: an auto-increment integer id or a UUID.
The database guarantees no two rows share the same primary key value.
Remember
Primary key = unique ID of each row.