Joe Celko's SQL for Smarties: Advanced SQL Programming, Third Edition

Chapter 22: Auxiliary Tables

Overview

Auxiliary tables are a way of building functions and lookup tables that would be difficult, if not impossible, to do with the limited computational power of SQL. What SQL is good at is working with tables. Auxiliary tables are not really a part of the data model, but serve as adjuncts to do queries via joins rather than computations.

Auxiliary tables are usually very static and are constructed from an outside data source. Thus they do not require the same constraint checking that dynamic tables do. As a general statement, they need to have a primary key declared so that it will create an index for searching and joining the auxiliary table to other tables in the schema, not to protect the data from redundancy.

The most important auxiliary table is a Calendar, because the Common Era calendar is too irregular for easy computations. Holidays fall on lunar and solar cycles, there are hundreds of fiscal calendars, and so forth. The discussion of Calendar tables will be given in the section on temporal queries. This chapter will examine various kinds of numeric auxiliary tables.

22.1 The Sequence Table

The Sequence table is a simple list of integers from 1 to ( n) that is used in place of looping constructs in a procedural language. Rather than incrementing a counter value, we try to work in parallel with a complete set of values.

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Lift Tables
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.