16.3. Other Kinds of Computed Data

Programmers coming from procedural languages are surprised to learn the SQL does not have a BOOLEAN data type. Their reaction is to use a proprietary BIT or BINARY data type to store flags, if their product has them, or to use a CHAR(1) with a constraint to allow only two values.

Flags like this should be replaced with the data that set them to their current state. For example, do not have an “is_delivered” flag when you could have the delivery date.

In the old punch card days, we would compute line totals in commercial application by multiplying the item quantity and unit price and punching the results in the right side of the card with special equipment. There was no place to keep the data except the cards. ...

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.