From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Dennis Gearon <gearond(at)fireserve(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: one to many |
Date: | 2004-05-17 02:02:19 |
Message-ID: | 20040516190016.E6978@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> Stephan Szabo wrote:
>
> >On Sun, 16 May 2004, Dennis Gearon wrote:
> >
> >
> >
> >>CC me please.
> >>
> >>How do I set up a one to many relationship in Postgres, (any DB for that
> >>matter.)
> >>
> >>I.E., if a delete or update of a child table causes a row in the parent
> >>table to no longer refer to any rows in the child table, to either cause
> >>Postgres to error out or delete the parent? I can see it does it for
> >>when a parent is upudated or deleted.
> >>
> >>
> >
> >I don't think there's any built in direct way to do this right now, but
> >you could probably build triggers that would do it for you (the current
> >foreign key triggers might give a starting point. You'd probably also
> >want to use CREATE CONSTRAINT TRIGGER to be able to defer the trigger
> >(similarly to how the foreign key deferred works).
> >
> >
> >
> >
> I didn't know you could set up triggers to be deferred! AWESOME! That
> makes for some additional flexibility that I could use.
>
> Thank you very much Stephen. I was beginnning to consider TRIGGERS as
> the solution; Now I know that they will work.
Well, I should note that AFAIK CREATE CONSTRAINT TRIGGER is considered an
"internal" feature. It's unlikely to go away until it's considered okay
to break compatibility with 7.0/7.1 dumps however (and would be more
likely to be replaced with a more general feature anyway).
From | Date | Subject | |
---|---|---|---|
Next Message | Sumita Biswas | 2004-05-17 02:10:07 | Function with RETURN TYPE RECORD Called From JAVA |
Previous Message | Kris Jurka | 2004-05-17 01:21:48 | Re: RTRIM always used with JDBC? |