Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

i have no idea on how make relationships(Forign key) between tables please give steps
Posted
Comments
Varun Sareen 22-Feb-12 4:17am    
accept the answer which best suits your problem and provide you the solution.

Follow the steps:-

1. To create a foreign key relationship in Table Designer

2. In Object Explorer, right-click the table that will be on the foreign-key side of the relationship and click Design.

3. The table opens in Table Designer.

4. From the Table Designer menu, click Relationships.

5. In the Foreign-key Relationships dialog box, click Add.

6. The relationship appears in the Selected Relationship list with a system-provided name in the format FK_<tablename>_<tablename>, where tablename is the name of the foreign key table.

7. Click the relationship in the Selected Relationship list.

8. Click Tables and Columns Specification in the grid to the right and click the ellipses (…) to the right of the property.

9. In the Tables and Columns dialog box, in the Primary Key drop-down list, choose the table that will be on the primary-key side of the relationship.

10. In the grid beneath, choose the columns contributing to the table's primary key. In the adjacent grid cell to the left of each column, choose the corresponding foreign-key column of the foreign-key table.

11. Table Designer suggests a name for the relationship. To change this name, edit the contents of the Relationship Name text box.

12. Choose OK to create the relationship.


**Note:-The columns you choose for the foreign key must have the same data type of the primary columns they correspond to. There must be an equal number of columns in each of the keys. For example, if the primary key of the table on the primary side of the relationship is made up of two columns, you will need to match each of those columns with a column in the table for the foreign key side of the relationship.


Please refer these links for more details:-

http://www.youtube.com/watch?v=xL7h4VQhXFY[^]

how to make foreign key relationship?

creating-primary-key-foreign-key-and-default-constraint/

I hope this will help you out.

Thanks
 
Share this answer
 
Comments
Madhugundi 22-Feb-12 4:07am    
Thanx
Sarvesh Kumar Gupta 22-Feb-12 4:22am    
MY 5
Varun Sareen 22-Feb-12 4:23am    
thanku sarvesh jee
Check these links

msdn.microsoft.com[^]

stackoverflow.com[^]
 
Share this answer
 
You know MSDN or Google?

Have a look at this Creating and Modifying FOREIGN KEY Constraints[^]

regards
Michel
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900