Re: Inheritance

From: "Zeugswetter Andreas SB SD" <ZeugswetterA(at)spardat(dot)at>
To: "Curt Sampson" <cjs(at)cynic(dot)net>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Greg Copeland" <greg(at)CopelandConsulting(dot)Net>, "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>, "PostgresSQL Hackers Mailing List" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Inheritance
Date: 2002-08-19 14:30:46
Message-ID: 46C15C39FEB2C44BA555E356FBCD6FA4961E4C@m0114.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> > > Yes, that's the whole point. If I have a constraint on a table, I think
> > > it should *never* be possible for that constraint to be violated. If a
> > > subtable should not have constraint the supertable has, it shouldn't
> > > inherit from the supertable.
> >
> > If you want that, you simply need to only create constraints that apply to
> > all tables in the hierarchy. Note that you *can* do this. It should imho be
> > the default behavior.
>
> So what you're saying is that constraints shouldn't be inherited?

No. I even said that inheriting should be the default.

> > > To do otherwise breaks the relational model.
> >
> > That is probably a point of argument. Imho the inheritance feature
> > is something orthogonal to the relational model. It is something else, and
> > thus cannot break the relational model.
>
> So then constraints must be inherited. The relational model, if I
> am not incorrect here, says that, given a table definition such as
> this:
>
> CREATE TABLE my_table (
> my_key int PRIMARY KEY,
> my_value text UNIQUE,
> my_other_value int CHECK (my_other_value > 0)
> )

A local constraint should be made obvious from looking at the schema,
a possible syntax (probably both ugly :-):
CHECK my_table ONLY (my_other_value > 0)
or
CHECK LOCAL (my_other_value > 0)

>
> You will never, ever, when selecting from this table, have
> returned to you
>
> 1. two rows with the same value of my_key but different values
> for the other columns,
>
> 2. two rows with the same value of my_value but different values
> for the other columns, or
>
> 3. a row in which the value of my_other_value is not
> greater than zero.
>

Well, that is where I do not think this is flexible enough, and keep in mind
that all triggers and rules would then also need such restrictions.

> I would strongly object to that.

Regardless whether your objection is *strong* or not :-)
If you don't like the feature (to add a local constraint), don't use it.
(Remember you are talking about removing an implemented feature)

Andreas

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-08-19 14:33:35 Re: Function result cacheing - any comments?
Previous Message Tom Lane 2002-08-19 14:18:25 Re: Page type