Database.Define the terms “simple”, “composite”, “candidate” and “alternate” keys.

🔑 1. Simple Key

  • A single attribute (column) that uniquely identifies a record.
  • Example:
    In a Users table, user_id is a simple key if it alone uniquely identifies each user.
user_id: 101, 102, 103

🧩 2. Composite Key

  • A combination of two or more attributes that together uniquely identify a record.
  • Used when no single column can serve as a unique identifier.
  • Example:
    In a CourseRegistrations table, the combination of student_id and course_id may form a composite key.
(student_id = 10, course_id = "CS101")

🎯 3. Candidate Key

  • Any attribute or combination of attributes that can uniquely identify a row in a table.
  • A table can have multiple candidate keys, but only one becomes the primary key.
  • Example:
    In a Users table:
    • user_id (unique number)
    • email (also unique)
    Both are candidate keys.

🔁 4. Alternate Key

  • A candidate key that was not chosen as the primary key.
  • It is still unique and may be used for lookup purposes.
  • Example:
    If user_id is the primary key, then email becomes the alternate key.

Summary Table

TermDefinition
Simple KeyA single attribute that uniquely identifies a record
Composite KeyTwo or more attributes combined to uniquely identify a record
Candidate KeyAny column or combination that can uniquely identify a record
Alternate KeyA candidate key not chosen as the primary key
This entry was posted in Без рубрики. Bookmark the permalink.