How primary keys work
Identify each row
A primary key is a column or column combination whose value uniquely identifies a row. Its value cannot be NULL.
Create an integer key
In SQLite, INTEGER PRIMARY KEY uses the rowid mechanism and generates a value when omitted.
CREATE TABLE students (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
);
Keep keys stable
Choose values that do not change when business details change. Email addresses and names can change, so generated numeric or UUID keys are common.
Know dialect syntax
PostgreSQL commonly uses identity columns; MySQL uses AUTO_INCREMENT. Avoid SQLite's AUTOINCREMENT unless you specifically require never-reused rowids.