Re: complex referential integrity constraints

From: "Robert Haas" <Robert(dot)Haas(at)dyntek(dot)com>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Alban Hertroys" <alban(at)magproductions(dot)nl>
Cc: "David Fetter" <david(at)fetter(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: complex referential integrity constraints
Date: 2007-02-23 14:39:52
Message-ID: 57653AD4C1743546B3EE80B21262E5CB11AA7E@EXCH01.ds.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Actually, what would be really nice is if there were just a button I
could push that would make all of my data automatically correct. Can
that go into 8.3? Thanks, ...Robert

-----Original Message-----
From: Alvaro Herrera [mailto:alvherre(at)commandprompt(dot)com]
Sent: Friday, February 23, 2007 9:35 AM
To: Alban Hertroys
Cc: Robert Haas; David Fetter; pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] complex referential integrity constraints

Alban Hertroys wrote:
> Robert Haas wrote:
> > The idea here is that a wolf can attack a sheep, or a wolf can
attack
> > another wolf, but sheep can't attack anything. I suppose I could
list
> > each wolf in both the predator and prey tables, but that seems a bit
> > duplicative (and causes other problems).
>
> I'm quite certain a wolf is much more likely to attack a sheep than to
> attack another wolf, and even more unlikely to attack for example a
> lion. It seems to me that just the fact that it can isn't enough
> information.
>
> It looks like you need "weighted constraints"; there's 0 chance that a
> sheep attacks a wolf, but there's >0 chance that a wolf attacks a
sheep,
> >0 chance it attacks a wolf and >0 chance it attacks a lion. The exact
> numbers will vary, and I have absolutely no idea what they would be
> like. It probably requires some kind of ranking system that adjusts
> according to the known animals and their likelihood to attack
eachother.

Depending on what you're modelling, even this could be too simple -- for
example, while a single wolf is unlikely to attack a lion, a pack of
wolves have a lot more probability of doing so.

Do you keep packs of wolves in your barn? If so, watch your lions.

--
Alvaro Herrera
http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karl O. Pinc 2007-02-23 14:46:27 Re: Supported plpgsql BEFORE ... EACH ROW behavior
Previous Message Marek Lewczuk 2007-02-23 14:38:03 Re: Warning "TupleDesc reference leak"