all topics

Relational Database Terminology

The formal names for the everyday parts

Every part of a table has a plain name and a more formal, relational-algebra name for the exact same thing. Worth knowing both, the formal ones show up constantly in docs and textbooks.

  • Table → Relation. The table itself.
  • Row → Tuple. One record in the table.
  • Column → Field / Attribute. One property every row has.
  • Number of rows → Cardinality. How many tuples the relation currently holds.
  • Number of columns → Degree. How many attributes the relation is defined with.

So a table with 3 columns and 100 rows is, formally, a relation of degree 3 and cardinality 100.

Candidate, primary, and alternate keys

Three related terms for the columns that could uniquely identify a row, and which one actually ends up doing the job.

  • Candidate key: any column, or combination of columns, that could uniquely identify each row, a genuine candidate for the job of primary key.
  • Primary key: whichever one candidate key actually gets chosen to do that job. Out of every candidate available, exactly one becomes the primary key.
  • Alternate key: every candidate key that wasn't picked. Still perfectly capable of uniquely identifying a row, just not the one selected.

Concretely: say a table has 10 candidate keys. 1 of them gets chosen as the primary key, and the other 9 become alternate keys. Every alternate key is a candidate key, and the primary key is a candidate key too, it's just the one candidate that got promoted.