Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

Explain the use of ‘Foreign Key’ in a Relational Database Management System. Give example to support your answer.

 

Answer:

A foreign key is used to represent the relationship between 2 tables in a database. It is an attribute whose value is derived from the primary key of another table.

Example:

Department

Dept_id

Dept_name

1011

Sales

1021

IT

1031

HR

Employee

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 is the primary key of table Department but in the table Employee, Dept_id is a foreign 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.