Re: OO and relation "impedance mismatch"
Date: Tue, 05 Oct 2004 13:00:35 -0400
Message-ID: <kvjujc.gh3.ln_at_mercury.downsfam.net>
Tony Andrews wrote:
>> > Presumably you don't mean that the tables wouldn't ALSO have
> primary,
>> > unique, foreign key constraints do you? >> >> Correct, they would not also have the constraints. The purpose is to >> completely control error reporting and have it behave the same way
> across
>> all platforms, and declarative constraints don't let me do that.
>
> Well I don't agree with that. Have triggers IN ADDITION to the
> constraints if you like, to improve the "user experience", but I would
> NEVER dispense with such fundamental integrity constraints as primary
> keys, foreign keys etc. Why?
>
> - Database constraints ensure integrity in a "foolproof" and performant
> manner
so does a trigger. The constraint can be removed by an administrator and so can the trigger. They are functionally equivalent and offer precisely the same level of protection.
>
> - It is extremely difficult (if not impossible) to write such
> constraints in procedural code. How do you prevent 2 users
> simultaneously entering a record with the same "primary key" if you
> don't have a primary key (or unique) constraint? Do you lock the whole
> table during insert statements?
It is not hard to manage. It would be really hard and silly to do it by hand, coding all of those triggers, but that's why I generate the triggers out of the data dictionary.
>
> - Database constraints can be used by the optimizer to determine the
> best query plan
so can indexes, which have to be there anyway if you use triggers.
>
> No, what you are doing is throwing away decades of development by the
> DBMS vendors and making yourself decades of work, plus a database that
> won't perform as well as it should, and will likely have plenty of data
> corruption in it.
>
> IMHO, I suppose I'd better add!
Crucial crucial point: I do things this way because it is *easier* for me. If it took decades, I could not make a living because I do real development, not theoretical work.
Now, having made that blustery and possibly flame-inducing statement, I should add that work on my current vision began only a few months ago, so I cannot publish anything at this time, so I am completely vulnerable to the retort, "Show me the code, Ken!" Since I have not published so much as Version 0.1, claims made in this thread are totally my unsubstantiated opinion.
-- Kenneth Downs Use first initial plus last name at last name plus literal "fam.net" to email meReceived on Tue Oct 05 2004 - 19:00:35 CEST