Re: Database Design Question - any suggestion?
Date: 9 Dec 2004 13:36:43 -0800
Message-ID: <1102628203.603305.256220_at_f14g2000cwb.googlegroups.com>
>> This would force a rebuild of the constraint for every new product
type.<<
Why would I not wish to have new constraints on the new product types? What kind of business rule is "The new stuff can wrong, but the old stuff has to be right!" ?
>> I come from the type that leaves all checking to the application if
possible. Depending on your use of this database, I think response time
is a very important factor for most and check constraints can slow
things down in an OLTP environment. <<
- If the data does not have to be right, then I can be VERY fast :) The answer is 42 and I don't care what the question was.
- CHECK()constraints are usually not that expensive to execute. 80-90% of them are simple range checks and 10-15% are string predicates that can be done with the local version of SIMILAR TO (the Standard SQL version of grep()).
Since the backend is usually bigger and faster than the front ends, the constraints should take less clock time.
The remaining 5% or so of constraints that cost time involve other tables -- say, running a current total to prevent an overdrawn account. Unfortunately, even today, a lot of SQL engines have to do this with triggers and procedural code instead of the SQL-99 CHECK() constraints that allow multi-table predicates.