Differentiate between the primary key and alternate key of a table with the help of an example.

 

Answer:

  • Primary key refers to a set of one or more attributes which can uniquely identify tuples in a relation. 
  • Alternate key refers to any candidate key which is not selected as the primary key.

Example:

Employee_id

Employee_name

Department

Emp_Email

101

Ravi Kumar

Sales

ravi1@gmail.com

102

Tarun A

IT

ta121@gmail.com

103

Jennifer Davis

HR

jenny@gmail.com

104

Martin Woods

HR

martin@gmail.com

105

Ron Romy

IT

roro@gmail.com

 

In table employee, the candidate keys are Employee_id and Emp_Email since we can uniquely identify an employee with either of the two.

If we select Employee_id as the primary key, then Emp_Email becomes an alternate key. 


Transcript

Differentiate between the primary key and alternate key of a table with the help of an example. Answer: Primary key refers to a set of one or more attributes which can uniquely identify tuples in a relation. Alternate key refers to any candidate key which is not selected as the primary key. Example: Employee_id Employee_name Department Emp_Email 101 Ravi Kumar Sales ravi1@gmail.com 102 Tarun A IT ta121@gmail.com 103 Jennifer Davis HR jenny@gmail.com 104 Martin Woods HR martin@gmail.com 105 Ron Romy IT roro@gmail.com In table employee, the candidate keys are Employee_id and Emp_Email since we can uniquely identify an employee with either of the two. If we select Employee_id as the primary key, then Emp_Email becomes an alternate key.

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.