Primary key vs foreign key in a relational table

Verdict: A primary key uniquely identifies each row within its own table; a foreign key stores another table's primary key value to link rows, and the RDBMS enforces referential integrity so it must match an existing primary key.

CriterionPrimary keyForeign key
PurposeUniquely identifies a row in its own tableReferences a related table's primary key to link rows
UniquenessMust be unique within the tableMay repeat; not required to be unique
Integrity enforcementIs the identity every foreign key must matchRDBMS enforces referential integrity: value must match an existing primary key
ExampleCustomer.CustomerId identifies each customer rowOrder.CustomerId references Customer.CustomerId

Rules

Traps