← All concepts
TechnologyDatabase

Databases, SQL & normalization

The relational model, keys, normalization to 3NF, ACID, and core SQL.

Relational basics

  • Data lives in tables (relations) made of rows (records) and columns (fields).
  • A primary key uniquely identifies a row; a foreign key references another table's primary key, linking the two.

Normalization

  • 1NF: atomic values only — no repeating groups or lists in a cell.
  • 2NF: 1NF and no non-key column depends on only *part* of a composite key.
  • 3NF: 2NF and no *transitive* dependency (non-key column depending on another non-key column).

ACID (transaction guarantees)

  • Atomicity — all steps happen, or none do.
  • Consistency — a transaction moves the DB from one valid state to another.
  • Isolation — concurrent transactions don't corrupt each other.
  • Durability — once committed, data survives a crash.

Core SQL

SELECT name, score
FROM   results
WHERE  score >= 60
ORDER BY score DESC;
select, filter, and sort