Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Showing posts with label Foreign key. Show all posts
Showing posts with label Foreign key. Show all posts

Friday, 13 February 2015

Introduction:

What is foreign key is the most common question asked in interview from freshers. I have tried to explain foreign key in my article in detail i.e. definition, how to create it and implementation. 

What is a Foreign Key?

In simple words A FOREIGN KEY is field in one table which points to a PRIMARY KEY field in another table.
A foreign key is a column(s) in one table that references the primary key of another table. The purpose of the foreign key is to ensure referential integrity of the data.
The referenced table is called the parent table while the table with the foreign key is called the child table.

Implementation: Let’s understand the concept of foreign key constraint by implementing it on tables. For this we are going to create two table Dept_Table and Emp_table.


Introduction:
In this article I have explained the difference between Primary key and Foreign Key.  This is most commonly asked in the interview in case of Freshers.
 Primary Key vs Foreign Key. 
I have tried to list all the major differences between Primary Key and Foreign Key.