简体   繁体   中英

Create foreign key relationship in database

This is most likely a very silly question, I am not a programmer.

I have used visual studio to create a database for my application.

The table "CapitalPlan" has primary key "ProgramID" - this needs to be the foreign key in table "MilestoneData" field "ProgramID"

Can anyone please advise how I set up the "ProgramID" in "MilestoneData" to be a foreign key?

Image shows where I'm currently at (not very far!)

Much appreciated!

image: http://i1186.photobucket.com/albums/z373/barbsbargainsltd/cDatabase_zps52ddc806.jpg

Under each table (Milestone Data in your case) in designer you have a 'folder' named Keys . If you right click it, there is a New Foreign Key... option. Clicking it opens a dialog for you with numerous properties of the foreign key being created. You need an ellipsis on Tables And Columns Specification there - it opens a new dialog, allowing to adjust source and destination tables as well as key mapping.

This way is applicable for SQL Server Management Studio, but the image you provided suggests that the solution for VS should be identical.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM