Back to the 2024 paper

Unit 2: Relational Query Languages

20247m

Discuss about different keys used in database design with examples

Worked SolutionAI Assisted

Keys in Database Design with Examples:

  • Candidate Key: Minimal set uniquely identifies tuple. Example: Student {rollno}, {email} - both candidates.
  • Primary Key: Chosen candidate key to uniquely identify row, cannot be NULL. Example: rollno PK for Student.
  • Alternate Key: Candidate keys not chosen as primary. Example: email alternate.
  • Super Key: Any superset of candidate key. Example: {rollno, name}, {rollno, email} - super keys.
  • Foreign Key: Attribute in one table referencing PK of another for referential integrity. Example: Enroll(s_id) references Student(rollno).
  • Composite Key: Key with multiple attributes. Example: Enroll primary key (s_id, c_id).
  • Unique Key: Ensures uniqueness but allows one NULL (varies by DBMS).
  • Natural vs Surrogate: Natural uses real data (rollno), Surrogate artificial (auto-increment id).

Importance: ensure entity integrity, referential integrity, normalization, indexing.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.