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

[email protected]

102

Tarun A

1012

[email protected]

103

Jennifer Davis

1013

[email protected]

104

Martin Woods

1013

[email protected]

105

Ron Romy

1012

[email protected]

Dept_id is the primary key of table Department but in the table Employee, Dept_id is a foreign key.

Go Ad-free
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 and Computer Science at Teachoo