From: | Curt Sampson <cjs(at)cynic(dot)net> |
---|---|
To: | Hannu Krosing <hannu(at)tm(dot)ee> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Inheritance |
Date: | 2002-09-06 07:53:12 |
Message-ID: | Pine.NEB.4.44.0209061628300.818-100000@angelic.cynic.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 6 Sep 2002, Hannu Krosing wrote:
> > In most object-oriented languages (Eiffel being a notable exception, IIRC),
> > you can't specify constraints on objects. But in a relational database,
> > you can specify constraints on tables, and it should *never* *ever* be
> > possible to violate those constraints, or the constraints are pointless.
>
> That's not how real world (which data is supposed to model) operates ;)
Sure it is. Please don't blame the language for being wrong when you
incorrectly model things for your purposes. To chose a much simpler
and more obvious example: if you stored birthdate as a date only, and
someone complained that you're not born all day, but at a particular
time on that day, you don't blame the language for having the date type
not store the time of day. You fix your problem to use both a date and a
time to store that value.
If the language specifies that contstraints on tables are not to be
violated, then don't use those constraints when you don't want them.
> To elaborate on Gregs example if you have table GOODS and under it a
> table CAMPAIGN_GOODS then you may place a general overridable constraint
> valid_prices on GOODS which checks that you dont sell cheaper than you
> bought, but you still want sell CAMPAIGN_GOODS under aquiring price, so
> you override the constraint for CAMPAIGN_GOODS.
This looks like a classic case of incorrect modelling to me. Does the
good itself change when it becomes a campaign_good? No. The price
changes, but that's obviously not an integral part of the good itself.
So separate your price information from your good information, and then
you can do things like have campaign prices, multiple prices per good
(since you probably want to keep the original price information as
well), and so on.
I'm really getting the feeling a lot of these applications that
want table inheritance want it just to be different, not because
it provides anything useful.
I am completely committed to object-oriented programming, and use
inheritance heavily, so it's not that I don't understand or like the
concepts. But just because a concept works well in one type of use does
not mean it will do any good, or even not do harm, when brought into a
completely different world.
> SQL standard constraints should be non-overridable. I still think that
> Constraint triggers should be overridable/dynamic.
I still don't like it. Eiffel had good reasons for making the
constraints non-overridable. Other OO languages don't have constraints,
or they would probably do the same.
That said, I could live with dynamic dispatch, if the default were
to make it non-dynamic, and you had to add a special flag to make it
dynamic. That way it would be obvious to the casual user or a DBA
familiar with other databases but not postgres that something unusual is
going on.
cjs
--
Curt Sampson <cjs(at)cynic(dot)net> +81 90 7737 2974 http://www.netbsd.org
Don't you know, in this new Dark Age, we're all light. --XTC
From | Date | Subject | |
---|---|---|---|
Next Message | ljguo_1234 | 2002-09-06 08:09:59 | abou the cost estimation |
Previous Message | Zeugswetter Andreas SB SD | 2002-09-06 07:33:03 | Re: [PATCHES] Big number of "unused" pages as reported by |