Re: OO and relation "impedance mismatch"

From: Kenneth Downs <firstinit.lastname_at_lastnameplusfam.net>
Date: Mon, 04 Oct 2004 18:40:56 -0400
Message-ID: <ohjsjc.99t.ln_at_mercury.downsfam.net>


Troels Arvin wrote:

> On Sat, 02 Oct 2004 04:00:13 -0700, Fredrik Bertilsson wrote:
>

>> OO people often claims that there are an impedance mismatch between
>> the OO model and the relational model, that makes it very hard use a
>> relational database when you are using an OO programming language.

>

<big snip>

>
> I think that the impedance mismatch would be less of a problem, if
>
> 1. RDBMSes got better at useful error reporting,
> which the application layer could easily translate
> into meaningful error messages for the end user.
> That way, a lot of redundant, defensive error avoidance
> code could be torn out of the middle ware/application.
>

Ironically, this led me to ask how serious a performance penalty I would get if I discarded declarative RI and went back to the old-fashioned method of using triggers.

Consider a user attempting to commit a hand-typed row to a table. There are three errors. It is almost universal in the world to fail-on-first and tell the user about the first error you see. So he fixes it, hits save, and gets rewarded with the next error. Cursing under his breath he fixes it (assuming he can understand the message, a HUGE assumption), and hits save and is rewarded with a THIRD error.

Now he hates you, and no matter what you do, he will never love you.

So many years ago I started coding a tell-me-everything-I-did-wrong approach to error reporting, where it says, "Save failed on the following 3 errors:..."

Sadly, you cannot do this with declarative constraints. The db products I have used, SQL Server and DB/2, both operate on fail-on-first mode, and you get a vendor message instead of your own lovingly crafted and easy to understand helpful suggestion.

But if you use a trigger, you can do tell-me-everything-I-did-wrong. The best I have so far come up with is to return a table of error codes and descriptions with each save attempt. An empty table is a successful save. This lets you provide descriptions to humans, or you can use the codes to do i18n translations, or use the code for automated error handling.

-- 
Kenneth Downs
Use first initial plus last name at last name plus literal "fam.net" to
email me
Received on Tue Oct 05 2004 - 00:40:56 CEST

Original text of this message