Creating a form to enter data in a table that contains a foreign key

Create Foreign Key Relationship
in SQL Server
Using the GUI interface
Creat Foreign Key 1
This example uses
tblMembership and
tblMembershipType tables
in Cape_Codd database on
Yorktown\dscidb
1. Right click the Keys
folder in the foreign
key table, then click
“New Foreign Key…”
Creat Foreign Key 2
2. On the “Foreign Key
Relationships” window, Select
“Tables And Columns Specific”,
then click
Creat Foreign Key 3
3. On the “Tables and Columns” window, type a Relationship
name. The name should follow this naming
convention: FK_PrimaryKeyTableName_ForeignKeyTableName.
For example: FK_tblMembershipType_tblMembership
4. Choose the Primary key table and primary key column. In
this example, the primary key table is
tblMembershipType and primary key is MembershipTypeID.
5. Choose the corresponding foreign key column in the
Foreign key table. In this example, the foreign key
table is tblMembership and foreign key is
MembershipTypeID. Then click OK to close the “Tables
and Columns” window.
Creat Foreign Key 4
6. On the “Foreign Key Relationships” window, select and
expand “INSERT And UPDATE Specification”, you can
specify the Delete Rule and Update Rule for the new
foreign key.
7. Click Close on the “Foreign Key Relationships” window.
Creat Foreign Key 5
8. Save the table definition
– Back in Step 1, the table with the new foreign key
(tblMembership) opened automatically in the design
window after you clicked “New Foreign Key…”
– You need to save the table before you can see your
new foreign key in the Keys folder of the table.
“Refresh” if necessary.