Course contentsShow
← Computer Science
Lesson 1614 of 2,87237. Database Design and NormalizationFree lesson

Key Attributes and Identifiers

Learning about primary keys, candidate keys, and how to uniquely identify entities within entity sets.

Key Attributes and Identifiers

You'll learn how to uniquely identify entities in a database using primary keys, candidate keys, and other identifiers.

The Core Idea

In an entity set (like a table of employees or products), you need a reliable way to tell one entity apart from all others. Key attributes are special attributes whose values uniquely identify each entity. Think of them like fingerprints—no two entities share the same combination of key attribute values.

Types of Keys

Primary Key

The primary key is the chosen identifier for an entity set. It's a single attribute (or minimal combination of attributes) that:

  • Uniquely identifies each entity
  • Cannot contain NULL values
  • Remains stable over time

Example: In an Employee entity set, employee_id might be the primary key.

Candidate Keys

Candidate keys are all possible attributes (or combinations) that could serve as primary keys. You choose one to be the primary key; the rest remain alternates.

Example: In a Student entity set:

  • student_id (primary key chosen)
  • email_address (candidate key)
  • ssn (candidate key)

Each could uniquely identify a student, but you pick the best one as primary.

The Analogy

Think of a classroom. You could identify students by:

  • Their student ID number (most reliable)
  • Their email (unique but might change)
  • Their seat number (changes every day—bad choice!)

All three could work, but student ID is the best primary key.

Key Takeaway: Primary keys uniquely and reliably identify entities, chosen from candidate keys that meet uniqueness and stability requirements.