Primary and Foreign Keys — a practical guide to SQL primary foreign keys with clear examples you can reuse in real projects.
ASP & ASP.NET Tutorial Series (183/247). Prefer one article? Read the complete ASP.NET tutorial.
Short description
Prefer surrogate int/guid keys unless natural keys are stable.
Keys tip
CREATE TABLE Items (
Id INT IDENTITY PRIMARY KEY,
CategoryId INT NOT NULL REFERENCES Categories(Id)
);