Ad Code

What is primary key or foreign key?


What is primary key or foreign key ? with some examples

The primary key uniquely identifies each row in the table / relation in the database and it can not be NULL. For example, there is a relation called Employee, and its attributes can be EmpID, EmpName, Address, Salary, Commission etc. By analysing deeply, we can found that many employees can have same address, salary, commission and Name, But EmpID can not be same. So, we can select this attribute as a primary key of this relation to find any values in the future.

A primary key attribute in a relation can be found in any other relation to join these two relations. In this case that primary key attribute would be called as foreign key attribute in that second relation.
Reactions

Post a Comment

0 Comments