Chapter 4. Lookup Tables

LOOKUP TABLES ARE a special case of auxiliary tables, but I wanted to treat them first since they are the most common case in real schemas. The “freshman” SQL programmer thinks that tables are the same as files and do not need to have any relationships among them enforced by declarative referential integrity (DRI) constraints. The “sophomore” SQL programmer was overly impressed by referential integrity constraints and assumes that all tables in a schema have to be linked via DRI. The better design for a schema lies somewhere in between.

A lookup table is used in SQL for the same purpose as a function or procedure in a computational language. For example, you can easily find the formula for the sine function and write ...

Get Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL 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.