Computer Science - Class 12
Chapter 8 - Database Concepts

What is primary key?

 

Answer:

Primary key is a set of one or more attributes which can uniquely identify each tuple of a relation.

Example:

Employee_id

Employee_name

Department

101

Ravi Kumar

Sales

102

Tarun A

IT

103

Jennifer Davis

HR

104

Martin Woods

HR

105

Ron Romy

IT

 

In the Employee table, the Employee_id of all employees are different . So it can be used to uniquely identify each employee and hence, we set Employee_id as the primary key.

Additional points:

  • A relation can have only 1 primary key.
  • A primary key can consist of single or multiple columns.
  • Primary keys must contain unique values.
  • Primary keys cannot contain NULL values.

Transcript

What is primary key? Answer: Primary key is a set of one or more attributes which can uniquely identify each tuple of a relation. Example: Employee_id Employee_name Department 101 Ravi Kumar Sales 102 Tarun A IT 103 Jennifer Davis HR 104 Martin Woods HR 105 Ron Romy IT In the Employee table, the Employee_id of all employees are different. So it can be used to uniquely identify each employee and hence, we set Employee_id as the primary key. Additional points: A relation can have only 1 primary key. A primary key can consist of single or multiple columns. Primary keys must contain unique values. Primary keys cannot contain NULL values.

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.