| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: foundations of relational theory?
cmurthi wrote:
> Marshall Spight wrote:
>> I'd still argue that a declarative integrity enforcement >> system is better than a procedural one.
Using the Informix dialect of SQL, and ignoring SQL NULL values (since they make a mess of everything), you could do:
ALTER TABLE WhatNot ADD CONSTRAINT ((field3 = '' AND field1 = field2) OR (field3 != '' AND field1 = field3));
You could give the constraint a name - though ISO SQL and Informx manage to do that differently. You could also include that declarative constraint in the CREATE TABLE statement.
I don't regard that as a particularly complex constraint. I'm not sure that it is part of a good database design, but that is probably simply because it is illustrative rather than anything else.
The big advantage of the declarative constraint is that the DBMS enforces it. No application can violate it, whether accidentally or on purpose. If the constraint becomes obsolete, then you drop it. Altering it is a two-stage drop and add operation (which Informix permits you to do in a single ALTER TABLE statement, so there is no window of vulnerability while you are changing the constraint).
-- Jonathan Leffler #include <disclaimer.h> Email: jleffler_at_earthlink.net, jleffler_at_us.ibm.com Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/Received on Tue Oct 28 2003 - 11:24:14 CST
![]() |
![]() |