June 2010
Intermediate to advanced
328 pages
7h 51m
English
Restricting a column’s values to a fixed set of values is very useful. If we can ensure that the column never contains an invalid entry, it can simplify use of that column. For example, in the Bugs table of our example database, the status column indicates whether a given bug is NEW, IN PROGRESS, FIXED, and so on. The significance of each of these status values depends on how we manage bugs in our project, but the point is that the data in the column must be one of these values.
Ideally, we need the database to reject invalid data:
| 31-Flavors/obj/insert-invalid.sql | |
| | INSERT INTO Bugs (status) VALUES ('NEW'); -- OK |
| | |
| | INSERT INTO Bugs (status) VALUES ('BANANA'); -- Error! |
Read now
Unlock full access