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

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.