From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | Ladislav Lenart <lenartlad(at)volny(dot)cz> |
Cc: | "List, Postgres" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: [PG9.1] CTE usage |
Date: | 2013-09-16 15:12:01 |
Message-ID: | 52371FC1.6090003@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 09/16/2013 07:38 AM, Ladislav Lenart wrote:
> On 16.9.2013 15:50, Adrian Klaver wrote:
>> On 09/16/2013 04:57 AM, Ladislav Lenart wrote:
>>> On 16.9.2013 13:26, Alban Hertroys wrote:
>>
>> .."
>
>
> Hello.
>
> Thank you but I have read this in the official documentation before posting my
> (previous) reply. So to quote the important bit about CASCADE:
>
> Delete any rows referencing the deleted row
>
> My example defines the table item with FK to the table item_type1 and FK to the
> table item_type2. Specifying anything on these two constraints does not help one
> bit when I delete an item, because item_type1 nor item_type2 does not reference
> any... Therefore I suspect that Alban Hertroys had a different model in mind where:
> * item would not have any FKs,
> * item_type1 would have FK to item,
> * item_type2 would have FK to item?
>
> I just wasn't sure, hence I have asked him for a more detailed answer. However,
> I am pretty sure ON DELETE CASCADE would not help in my current setup.
I guess the question is whether you actually have set up FK
relationships between items.item_type1_id, items.item_type2_id and the
respective ids in item_type1 and item_type2?
In other words do you have REFERENCE item_type1 ... on item_type1_id?
If so and you add the ON DELETE CASCADE, you could DELETE from
item_type1 and it would delete the respective items rows.
>
> Ladislav Lenart
>
>
>
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Ladislav Lenart | 2013-09-16 15:23:06 | Re: [PG9.1] CTE usage |
Previous Message | Merlin Moncure | 2013-09-16 14:41:18 | Re: Best way to populate nested composite type from JSON` |