Ir al contenido principal

What are Candidate, Primary and Foreign Keys?


  • CK (Candidate Key). These are the Keys that may be defined as Primary keys, and must enforce these properties.
    • Properties:
      • Uniqueness. It must have a unique value, that is we cannot have at any given time the same value for the attribute at more than one tuple. Example: we cannot have the same SSN for two or more individuals, or a person can't have more than one SSN.
      • Minimality. If it is a composite attribute (as an address), no component of the attribute can be deleted without destroying the uniqueness property.
  • PK (Foreign Key). The most representative CK or CKs (we can have a composite PK) of the Entity Set are selected to use them to identify each Entity of an Entity Set. Example: The Entity Set "Student" has "Student Identification Number" as a PK.
  • FK (Foreign Key). What if we have a table with Students which include, for each student, the "Identification Number" of each student's advisor (that is the PK of "Student advisor" in "Student advisors" table)? Easy! That will be a FK, because is a PK of another table appended to our main table.


Comentarios