Skip to content

Information Technology · Ch 2 — Introduction to DBMS

Keys in a Relational Database

6

Keys in a Relational Database

A key is a field (or a combination of fields) used to identify records in a table and to link tables together. Keys are what make the relational model powerful, because they let separate tables be joined meaningfully.

Primary key: a primary key is a field (or set of fields) whose value uniquely identifies each record in a table. No two records may have the same primary-key value, and the value can never be left empty (blank/NULL). In the Student table above, RollNo is a natural primary key, because every student has a different roll number and it is never blank. A primary key guarantees that each record can be picked out with no confusion.

Candidate key: sometimes a table has more than one field that could serve as a primary key — each such field is a candidate key. From among the candidate keys, the designer chooses one to be the primary key.

Composite (compound) key: when no single field is unique on its own, two or more fields together can form the key. Such a key made of more than one field is called a composite key. For example, in a table recording marks per subject, the combination RollNo + SubjectCode may be needed to identify each row uniquely. …

Definition 1Primary key

A field (or set of fields) whose value uniquely identifies each record in a table; it must be unique and must never …

Definition 2Foreign key

A field in one table whose values refer to the primary key of another table, thereby creating a relationship (link) be …

Definition 3Composite key

A key formed by combining two or more fields together to uniquely identify a record, used when no single field i …