Getting a Good Join

What makes for a good join column? Ideally, a join column is a key column for its table—either a primary key or a foreign key. When a key is composite (made up of more than one column), you can join on all the columns of the key.

Since the primary key logically connects to related foreign key columns in other tables, key columns are usually ideal candidate columns on which to construct a join. Such a join is likely to be useful and logically appropriate because the database designer planned ahead for it.

Primary key/foreign key joins are based on the expectation that foreign keys will be kept consistent with their primary keys, in order to preserve the referential integrity of the database. See “Creating Tables with SQL-92 ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition 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.