O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying a Foreign Key with FOREIGN KEY

I described foreign keys in “Foreign Keys” in Chapter 2, but I’ll review the basics here:

  • A foreign key is a mechanism that associates two tables.

  • A foreign key is a column (or set of columns) in a table whose values relate to, or reference, values in some other table.

  • A foreign key ensures that rows in one table have corresponding rows in another table, called the referenced table or parent table.

  • A foreign key establishes a direct relationship to a primary key or candidate key in the referenced table, so foreign-key values are restricted to parent-key values that already exist. This restriction is called referential integrity.

  • A foreign key, unlike a primary key, can permit nulls.

  • A table can have zero ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required