June 2010
Intermediate to advanced
328 pages
7h 51m
English
Science is feasible when the variables are few and can be enumerated; when their combinations are distinct and clear.
In a personal contact information table, the salutation is a good example of a column that can have only a few values. Once you support Mr., Mrs., Ms., Dr., and Rev., you’ve accounted for virtually everyone. You could specify this list in the column definition, using a data type or a constraint, so that no one can accidentally enter an invalid string into the salutation column.
| 31-Flavors/intro/create-table.sql | |
| | CREATE TABLE PersonalContacts ( |
| | -- other columns |
| | salutation VARCHAR(4) |
| | CHECK (salutation IN ('Mr.', 'Mrs.', 'Ms.', 'Dr.', 'Rev.')), |
| | ); |
That should settle it—there ...
Read now
Unlock full access