×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Primary key - RDBMS
Foreign key - RDBMS - SQL
73    Arnab De    21/11/2021   

A non-key attribute, whose values are derived from the primary key of another table, is known as foreign key.

  • The foreign key of a table should declare as a primary key in another table.
  • The name of the primary key and foreign key may or may not be same but their data type and length of the field should same.
  • The every value of the foreign keys should present in the master table as primary key. Primary key values are unique, but the same value in foreign key may present more than one times.

For example, Lets Consider, two relation called emp and dept

softetechnologies
emp
Emp_SSN Emp_No Emp_Name Dept
1234544434 E-001 Pradipta Pal 20
5345232444 E-002 Abhijit Ganguly 30
4645673422 E-003 Suman Banerjee 30
dept
Dno Dname
20 Sales
30 Production
softetechnologies

Here,Dept column in emp table is a foreign key as it points to the primary key of the dept table. Here name of the primary key of dept(Dno) and foreign key of emp(Dept) are not same but their data type and length of the field should be same. And dno of sales department appear more than one once in emp table as foreign key.

Primary key - RDBMS
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Sri Sri Ramakrishna Paramahamsa
The supreme purpose and goal for human life... is to cultivate love.
Sri Sri Ramakrishna Paramahamsa
2128
25.81
Today So Far
Total View (Lakh)
softetechnologies
01/01/2018     31584
28/06/2017     26610
02/08/2017     23330
26/05/2018     21526
15/05/2017     20223
06/07/2017     19001
01/08/2017     17464
21/04/2018     17236
01/07/2017     14866
25/04/2018     14109
softetechnologies