Sobes.tech
Junior

What is a potential (candidate) key in databases?

sobes.tech AI

Answer from AI

A potential (candidate) key is a column or set of columns in a table that can uniquely identify each record. From all potential keys, one is chosen as the primary key. The other potential keys, not selected as the primary, are called alternate keys.

Main properties of a potential key:

  • Uniqueness: Values in all rows must be unique.
  • Immutability: The value should be stable and not change frequently.
  • Necessity: It should not contain columns that are not needed for unique identification.

Example: In the customers table, potential keys could be customer_id, email (if unique), or a combination of first_name and date_of_birth (under certain conditions).