pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedIs it possible to have a cascade upwards query?
4+ messages / 4 participants
[nested] [flat]
* Is it possible to have a cascade upwards query?
@ 2019-03-27 15:58 Mike Martin <redtux1@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Mike Martin @ 2019-03-27 15:58 UTC (permalink / raw)
To: pgsql-general
As per title, is this possible?
Scenario being two tables with a linking pair of fields, where one table is
a superset of the other and key is generated by the second table
I would like to have the record in table two deleted when I delete the
record in table 1
Thanks
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is it possible to have a cascade upwards query?
@ 2019-03-27 16:15 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Mike Martin <redtux1@gmail.com>
1 sibling, 1 reply; 4+ messages in thread
From: Adrian Klaver @ 2019-03-27 16:15 UTC (permalink / raw)
To: Mike Martin <redtux1@gmail.com>; pgsql-general
On 3/27/19 8:58 AM, Mike Martin wrote:
> As per title, is this possible?
>
> Scenario being two tables with a linking pair of fields, where one table
> is a superset of the other and key is generated by the second table
>
> I would like to have the record in table two deleted when I delete the
> record in table 1
Sorry not enough coffee in me yet to figure the above out:)
Could you provide a simple diagram(schema) to illustrate?
>
> Thanks
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is it possible to have a cascade upwards query?
@ 2019-03-27 16:18 Joseph Testa <info@dbsec-it.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 4+ messages in thread
From: Joseph Testa @ 2019-03-27 16:18 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Mike Martin <redtux1@gmail.com>; pgsql-general
Is this like a cascade delete based on constraints(like in the oracle
world), delete parent and all children go away also?
joe
On Wed, Mar 27, 2019 at 12:15 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:
> On 3/27/19 8:58 AM, Mike Martin wrote:
> > As per title, is this possible?
> >
> > Scenario being two tables with a linking pair of fields, where one table
> > is a superset of the other and key is generated by the second table
> >
> > I would like to have the record in table two deleted when I delete the
> > record in table 1
>
> Sorry not enough coffee in me yet to figure the above out:)
>
> Could you provide a simple diagram(schema) to illustrate?
>
> >
> > Thanks
> >
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is it possible to have a cascade upwards query?
@ 2019-03-27 16:37 David G. Johnston <david.g.johnston@gmail.com>
parent: Mike Martin <redtux1@gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: David G. Johnston @ 2019-03-27 16:37 UTC (permalink / raw)
To: Mike Martin <redtux1@gmail.com>; +Cc: pgsql-general
On Wed, Mar 27, 2019 at 8:58 AM Mike Martin <redtux1@gmail.com> wrote:
> Scenario being two tables with a linking pair of fields, where one table
> is a superset of the other and key is generated by the second table
>
> I would like to have the record in table two deleted when I delete the
> record in table 1
>
Since table 1 is a superset of table 2 there is no foreign key possible on
which the system provided ON DELETE CASCADE could be specified. You will
need to create your own trigger to perform the deletion on table 2.
David J.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2019-03-27 16:37 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-03-27 15:58 Is it possible to have a cascade upwards query? Mike Martin <redtux1@gmail.com>
2019-03-27 16:15 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-03-27 16:18 ` Joseph Testa <info@dbsec-it.com>
2019-03-27 16:37 ` David G. Johnston <david.g.johnston@gmail.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