Tuesday, May 22, 2012

sql server:how to create a foreign key relationship

Here i will show how to create a foreign  key relation between two tables in server.The parent table must have the primary key field when we will giving the foreign key with child table.For this we have to right click on the child table ,select relationships then  we will get a pop like as in screen.In this pop up we have an option "Table and column specification" ,,then we have to select circled option  which is right to blue color field.
We will get an option to select which  tables has to be involved in  foreign key relation as in below screen.Here the emp ,table_3 are table's are used
 The ID is the primary key field in emp table is foreign key relation with id in table_3 table.we can see this process as in below 2 images

After all process has done ,we can see the which table and columns are involved in this relationships

No comments:

Bel