pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCascading Deletes
4+ messages / 4 participants
[nested] [flat]
* Cascading Deletes
@ 2000-09-06 17:21 Craig May <craig.may@s2.enthdimension.com.au>
0 siblings, 2 replies; 4+ messages in thread
From: Craig May @ 2000-09-06 17:21 UTC (permalink / raw)
To: pgsql-sql
Hi,
I have a tables having this structure:
ID (int) | _ID (int) | Name (String)
_ID is the parent of ID.
I'm looking for the best method to perform a cascade delete. For example, I
delete _ID, it in turn deletes ID, and should ID also be an entry within _ID, it
would continue through the chain.
For example:
0 0 Base
1 0 Sib1
2 0 Sib2
3 0 Sib3
4 1 Sib1_1
5 1 Sib1_2
Deleting Base would remove all the entries. Deleting Sib1 would delete Sib1_1
and Sib1_2.
Can anyone help out here?
Regards,
Craig May
Enth Dimension
http://www.enthdimension.com.au
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Cascading Deletes
@ 2000-09-06 17:50 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: Craig May <craig.may@s2.enthdimension.com.au>
1 sibling, 0 replies; 4+ messages in thread
From: Stephan Szabo @ 2000-09-06 17:50 UTC (permalink / raw)
To: Craig May <craig.may@s2.enthdimension.com.au>; +Cc: pgsql-sql
I think a references constraint on ID
referencing _ID with ON DELETE CASCADE
should do what you want.
Stephan Szabo
sszabo@bigpanda.com
On Wed, 6 Sep 2000, Craig May wrote:
> Hi,
>
> I have a tables having this structure:
>
> ID (int) | _ID (int) | Name (String)
>
>
> _ID is the parent of ID.
>
> I'm looking for the best method to perform a cascade delete. For example, I
> delete _ID, it in turn deletes ID, and should ID also be an entry within _ID, it
> would continue through the chain.
>
> For example:
>
> 0 0 Base
> 1 0 Sib1
> 2 0 Sib2
> 3 0 Sib3
> 4 1 Sib1_1
> 5 1 Sib1_2
>
>
> Deleting Base would remove all the entries. Deleting Sib1 would delete Sib1_1
> and Sib1_2.
> Can anyone help out here?
>
> Regards,
> Craig May
>
> Enth Dimension
> http://www.enthdimension.com.au
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Cascading Deletes
@ 2000-09-06 18:12 Jie Liang <jliang@ipinc.com>
parent: Craig May <craig.may@s2.enthdimension.com.au>
1 sibling, 0 replies; 4+ messages in thread
From: Jie Liang @ 2000-09-06 18:12 UTC (permalink / raw)
To: craig.may@s2.enthdimension.com.au; +Cc: pgsql-sql
Hi, there,
2 ways may resolve you problem, I believe:
1. re_create your table set _ID as primary key and ID as foreign key with option ON
DELETE CASCADE
if _ID is unique key.
2. create a rule bind this table, for each row deleting(or create a trigger).
Craig May wrote:
> Hi,
>
> I have a tables having this structure:
>
> ID (int) | _ID (int) | Name (String)
>
> _ID is the parent of ID.
>
> I'm looking for the best method to perform a cascade delete. For example, I
> delete _ID, it in turn deletes ID, and should ID also be an entry within _ID, it
> would continue through the chain.
>
> For example:
>
> 0 0 Base
> 1 0 Sib1
> 2 0 Sib2
> 3 0 Sib3
> 4 1 Sib1_1
> 5 1 Sib1_2
>
> Deleting Base would remove all the entries. Deleting Sib1 would delete Sib1_1
> and Sib1_2.
> Can anyone help out here?
>
> Regards,
> Craig May
>
> Enth Dimension
> http://www.enthdimension.com.au
--
Jie LIANG
Internet Products Inc.
10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873
jliang@ipinc.com
www.ipinc.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Cascading Deletes
@ 2000-09-07 04:23 K Parker <kparker@eudoramail.com>
0 siblings, 0 replies; 4+ messages in thread
From: K Parker @ 2000-09-07 04:23 UTC (permalink / raw)
To: pgsql-sql@hub.org
> 1. re_create your table set _ID as primary key
This is not going to work unless a parent is prohibited from having more than one child. From the brief sample data supplied, this is clearly not the case.
Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2000-09-07 04:23 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-09-06 17:21 Cascading Deletes Craig May <craig.may@s2.enthdimension.com.au>
2000-09-06 17:50 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2000-09-06 18:12 ` Jie Liang <jliang@ipinc.com>
2000-09-07 04:23 Re: Cascading Deletes K Parker <kparker@eudoramail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox