A foreign key constraint works in conjunction with primary key or unique constraints to enforce referential integrity among specified tables. For example, you can place a foreign key constraint on the title_id
column in the publishers
table to ensure that a value entered in that column matches an existing value in the title_id
column of the titles
table.
In database diagrams, a foreign key constraint is automatically placed on specified columns when you create a relationship to a table from another table to which a primary key or unique constraint is attached. For more information about creating relationships, see Creating a Relationship Between Tables.
To | See |
See which columns participate in the foreign key side of a relationship | Viewing Foreign Key Attributes |
Change which columns are related to columns in the primary key table | Modifying a Foreign Key |
Check existing data when creating a relationship | Checking Existing Data when Creating a Relationship |
Disable a foreign key constraint during INSERT and UPDATE transactions | Disabling a Foreign Key Constraint with INSERT and UPDATE Statements |
Disable a foreign key constraint during replication of the table | Disabling a Foreign Key Constraint for Replication |
Remove the requirement to enforce referential integrity between primary key columns and the related columns in another table | Deleting a Foreign Key Constraint |