pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: terry@greatgulfhomes.com
Cc: 'Jan Wieck' <janwieck@yahoo.com>
Cc: 'Achilleus Mantzios' <achill@matrix.gatewaynet.com>
Cc: pgsql-general@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] VIEWs and FOREIGN keys
Date: Mon, 10 Jun 2002 16:38:20 -0400
Message-ID: <8541.1023741500@sss.pgh.pa.us> (raw)
In-Reply-To: <002801c210af$9088c980$2766f30a@development.greatgulfhomes.com>
References: <002801c210af$9088c980$2766f30a@development.greatgulfhomes.com>

terry@greatgulfhomes.com writes:
> 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.

Got it in one.

One could perhaps imagine putting triggers on the table(s) that are
referenced by the view, but those triggers would have to do very slow
and expensive things to enforce the deletion constraint, at least in the
interesting cases where the view is a join, aggregation, GROUP BY, etc...

			regards, tom lane



view thread (8+ messages)  latest in thread

Message-ID: <8541.1023741500@sss.pgh.pa.us>
Permalink:  ../8541.1023741500@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8541.1023741500@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, terry@greatgulfhomes.com, janwieck@yahoo.com, achill@matrix.gatewaynet.com, pgsql-general@postgresql.org
  Subject: Re: [SQL] VIEWs and FOREIGN keys
  In-Reply-To: <8541.1023741500@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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