Check sibling questions
Computer Science - Class 12
Chapter 8 - Database Concepts

What are keys? Name all the keys used in DBMS.

 

Answer:

  • A key is an attribute or set of attributes that help to identify records in a table.
  • To retrieve data from more than one table, we join the tables using keys .
  • It also controls and maintains integrity of information stored in the database.
  • The various types of keys are:
  1. Primary key
  2. Candidate key
  3. Alternate key
  4. Foreign key

Example:

Employee_id

Employee_name

Dept_id

Emp_Email

101

Ravi Kumar

1011

ravi1@gmail.com

102

Tarun A

1012

ta121@gmail.com

103

Jennifer Davis

1013

jenny@gmail.com

104

Martin Woods

1013

martin@gmail.com

105

Ron Romy

1012

roro@gmail.com

 

Dept_id

Dept_name

1011

Sales

1021

IT

1031

HR

 

In table Employee,

  • Primary key - Employee_id
  • Candidate keys - Employee_id,Emp_Email
  • Alternate key - Emp_Email
  • Foreign key - Dept_id

In table Department,

  • Primary key - Dept_id

Transcript

What are keys? Name all the keys used in DBMS. Answer: A key is an attribute or set of attributes that help to identify records in a table. To retrieve data from more than one table, we join the tables using keys. It also controls and maintains integrity of information stored in the database. The various types of keys are: Primary key Candidate key Alternate key Foreign key Example: Employee_id Employee_name Dept_id Emp_Email 101 Ravi Kumar 1011 ravi1@gmail.com 102 Tarun A 1012 ta121@gmail.com 103 Jennifer Davis 1013 jenny@gmail.com 104 Martin Woods 1013 martin@gmail.com 105 Ron Romy 1012 roro@gmail.com Dept_id Dept_name 1011 Sales 1021 IT 1031 HR In table Employee, Primary key - Employee_id Candidate keys - Employee_id,Emp_Email Alternate key - Emp_Email Foreign key - Dept_id In table Department, Primary key - Dept_id

Davneet Singh's photo - Teacher, Engineer, Marketer

Made by

Davneet Singh

Davneet Singh is a graduate from Indian Institute of Technology, Kanpur. He has been teaching from the past 12 years. He provides courses for Maths and Science at Teachoo.