Re: [SQL] VIEWs and FOREIGN keys

From: terry(at)greatgulfhomes(dot)com
To: "'Jan Wieck'" <janwieck(at)yahoo(dot)com>, "'Achilleus Mantzios'" <achill(at)matrix(dot)gatewaynet(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [SQL] VIEWs and FOREIGN keys
Date: 2002-06-10 18:49:33
Message-ID: 002801c210af$9088c980$2766f30a@development.greatgulfhomes.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

I would just like to elaborate, and clarify if my understanding is correct:

The implication of below is that you need a trigger in the foreign key
target table on the DELETE event, so the foreign key table only lets you
delete a row if there are no other tables refering to the key you want to
delete.

Views cannot have triggers, hence cannot have a DELETE trigger, therefore
that is why the view cannot be a foreign key target table.

Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes
terry(at)greatgulfhomes(dot)com

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Jan Wieck
> Sent: Monday, June 10, 2002 1:20 PM
> To: Achilleus Mantzios
> Cc: pgsql-general(at)postgresql(dot)org; pgsql-sql(at)postgresql(dot)org
> Subject: Re: [GENERAL] [SQL] VIEWs and FOREIGN keys
>
>
> Achilleus Mantzios wrote:
> >
> > can someone have a foreign key constraint that references
> > a view??
>
> No, and this is not planned either. Remember that it is not
> only required for referential integrity to check if a key
> exists on INSERT or UPDATE to the referencing table. The
> system must guarantee that you cannot remove existing keys
> while they are referenced (or more precise perform the
> requested referential action).
>
>
> Jan
>
> --
>
> #=============================================================
> =========#
> # It's easier to get forgiveness for being wrong than for
> being right. #
> # Let's break this rule - forgive me.
> #
> #==================================================
> JanWieck(at)Yahoo(dot)com #
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Roberto Nanamura 2002-06-10 19:05:26 Poor performance in Porting Oracle based application to PostgreSQL
Previous Message Scott Marlowe 2002-06-10 18:47:39 Re: Help with data transfer please

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 2002-06-10 19:19:36 Re: [SQL] VIEWs and FOREIGN keys
Previous Message Bruce Momjian 2002-06-10 18:33:45 Re: [HACKERS] Efficient DELETE Strategies