Re: OO and relation "impedance mismatch"

From: Tony Andrews <andrewst_at_onetel.com>
Date: 5 Oct 2004 12:01:15 -0700
Message-ID: <1097002875.481123.247110_at_k26g2000oda.googlegroups.com>


Kenneth Downs wrote:
> > - 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.

I don't believe they do. Well: I KNOW that they don't in Oracle, I cannot be 100% sure about other DBMSs. I have given an example of why not in another post. Also, being procedural code, they probably cannot perform as well as a declarative constraint; again that's definitely true for Oracle, I don't know about others.

> > - 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.

But the data dictionary doesn't know what the constraint are, if you don't declare them?

> > - 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.

Non-unique indexes can't tell you whether a value is unique; unique indexes are more-or-less declarative constraints, so why not actually have the constraint?

> 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.

Well good luck, but I would urge you to work through all the concurrency issues, because I'm pretty sure you'll find it isn't as easy as you think to get it right. Received on Tue Oct 05 2004 - 21:01:15 CEST

Original text of this message