From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | SF Postgres <sfpug(at)postgresql(dot)org> |
Subject: | Best practices? |
Date: | 2003-09-30 19:13:00 |
Message-ID: | 20030930191300.GA8274@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | sfpug |
Kind people,
Please pardon me if this is a repost--my messing with procmail has
messed up a few things. Anyhow...
It's fairly common to have a situation like
"A foo may have one or more bars," as in
CREATE TABLE foo (
foo_id SERIAL PRIMARY KEY
);
CREATE TABLE bar (
bar_id SERIAL PRIMARY KEY
)
CREATE TABLE foo_bar (
foo_id INTEGER NOT NULL REFERENCES foo(foo_id) ON DELETE RESTRICT
, bar_id INTEGER NOT NULL REFERENCES bar(bar_id) ON DELETE RESTRICT
);
What I'd like to do is a more general:
For integers 0 <= m <= n <= infinity,
At the end of any transaction involving foo (including INSERT), a foo
must have between m and n bars.
Is there a standard way to approach this?
TIA for any pointers :)
Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2003-10-01 05:38:48 | Re: Best practices? |
Previous Message | David Fetter | 2003-09-30 17:03:57 | Best practices? |