tri_inn

tri_inn

  • NA
  • 1.2k
  • 222.1k

Why primary & foreign key is required for database table

Mar 2 2015 4:10 AM
we know that when we create pk on any table then a cluster index is created and pk do not allow null and duplicate value. so instead of pk we can create unique key on a fields then cluster index will be created and duplicate data will not be inserted. it would be helpful if some one discuss briefly why pk is required and its advantage.
 
the same way when we have table called employee and  employee_details and both have same field called empid and when we create relation from sql server diagram then automatically a fk will be created on employee_details table but i like to know if we do not create fk on employee_details table then we also can join two table for fetching data. so my question is if we can join 2 table to fetch data without fk then what is importance of fk and what will be the advantage of fk.
 
it will be helpful if some one discuss my points in details example for better understanding. thanks

Answers (3)