The FOREIGN KEY Referential Integrity Constraint

The basic premise of a relational database is that tables are related. These relationships are maintained and enforced via referential integrity. FOREIGN KEY constraints are the declarative means for enforcing referential integrity in SQL Server. You implement FOREIGN KEY constraints by relating one or more columns in a table to the columns in a primary key or unique index. The columns in the referencing table can be referred to as foreign key columns. The table with the primary key or unique index can be referred to as the primary table. Figure 22.2 shows a relationship between the BusinessEntityAddress table and AddressType table. The foreign key in this example is AddressTypeID on the BusinessEntityAddress ...

Get Microsoft® SQL Server 2012 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.