Relational Model & Keys

The vocabulary that every exam question assumes. Learn the three synonyms and the four key types cold.

REMEMBER: Table = Relation · Row = Tuple · Column = Attribute.
IDnamedept_namesalary
22222EinsteinPhysics95000
12121WuFinance90000
32343El SaidHistory60000
45565KatzComp. Sci.75000
98345KimElec. Eng.80000
76766CrickBiology72000
6 tuples · 4 attributes

Core terms

Domain (D): the set of allowed values for an attribute. e.g. D(salary) = positive integers between 30000 and 150000.
Atomic: attribute values are indivisible (no lists inside a cell).
null: a special value in every domain meaning “unknown”. It complicates many operations.

Schema vs Instance

A relation schema defines the structure: relation name, attribute names, and attribute domains.

INSTRUCTOR = (ID, name, dept_name, salary)        ← schema  R = (A₁, A₂, …, Aₙ)

Formally, given domains D₁…Dₙ, a relation r is a subset of D₁ × D₂ × … × Dₙ — a set of n-tuples. The current rows are the relation instance; one row is a tuple. Order of tuples is irrelevant.

Keys

Let K ⊆ R. Four kinds, each narrower than the last:

🔑 Super key

K is a super key if its values are sufficient to identify a unique tuple. May contain extra attributes.

e.g. {ID} and {ID, name} are both super keys of instructor.

🎯 Candidate key

A super key that is minimal — remove any attribute and it stops being a super key.

e.g. {ID} is a candidate key. {ID, name} is not (name is redundant).

⭐ Primary key

One candidate key chosen to identify tuples. If R = {ID, u_name, name, dept_name, salary} has candidate keys {ID} and {u_name}, the primary key is either {ID} or {u_name}.

🔗 Foreign key

An attribute whose value must appear as a key in another relation. The table with the FK is the referencing relation; the table it points to is the referenced relation.

e.g. dept_name in instructor is a foreign key referencing department.

Nesting: every primary key is a candidate key, and every candidate key is a super key — but not the reverse. Super ⊇ Candidate ⊇ Primary.