Re: The fable of DEMETRIUS, CONSTRAINTICUS, and AUTOMATICUS
Date: 20 Oct 2004 12:59:48 -0700
Message-ID: <1098302387.996382.76820_at_z14g2000cwz.googlegroups.com>
Laconic2 wrote:
> I hate to keep beating the same dead horse, but won't CREATE DOMAIN
do
> exactly this?
>
> CREATE DOMAIN valid_salary CONSTRAINT valid_salary BETWEEN 0 AND
100000;
>
>
> CREATE TABLE EMPLOYEES
> (...
> SALARY VALID_SALARY,
> ...);
Yes. But I think it is important to distinguish between 2 different
kinds of "rule":
The first is what a DOMAIN does: it is meant to be a permanent
restriction (like a data type definition). The second is a rule that
is very likely to change over time - perhaps annually say. I'm not
sure a DOMAIN change is appropriate for that. That's why I actually
agree with Kenneth that the user should be able to change it without
performing DDL. The way I would choose to do it would be to store the
maximum in a table, and then have a constraint to check the salary
1) "Salary IS a numeric value between 0 and 999999"
2) "Salaries are restricted (by current company policy) to a maximum of
100000"