Information Technology · Ch 3 — Relational Database Management System
Keys in a Relational Database
Keys in a Relational Database
A key is an attribute (or a combination of attributes) used to identify tuples in a relation and to link relations together. Keys are what make the relational model powerful, because they let separate tables be joined meaningfully without duplicating data.
Primary key. A primary key is an attribute (or set of attributes) whose value uniquely identifies each tuple in a relation. No two tuples 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 relation has more than one attribute that could serve as a primary key — each such attribute is a candidate key. From among the candidate keys, the designer chooses one to be the primary key.
Composite (compound) key. When no single attribute is unique on its own, two or more attributes together can form the key. Such a key made of more than one attribute 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. …
An attribute (or set of attributes) whose value uniquely identifies each tuple in a relation; it must be unique and must neve …
An attribute in one relation whose values refer to the primary key of another relation, thereby creating a relationship (link) …
A key formed by combining two or more attributes together to uniquely identify a tuple, used when no single attribute …