pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: M.D.G. Lange <mlange@dltmedia.nl>
Cc: pgsql-sql@postgresql.org
Subject: Re: rule or trigger?
Date: Tue, 7 Jun 2005 06:54:48 -0700 (PDT)
Message-ID: <20050607065228.O97782@megazone.bigpanda.com> (raw)
In-Reply-To: <42A576E5.1040100@dltmedia.nl>
References: <42A576E5.1040100@dltmedia.nl>

On Tue, 7 Jun 2005, M.D.G. Lange wrote:

> It is not possible to create a constraint Foreign key for "wordid". No
> problem there, but I want to be certain that a given wordid exists in
> tbldictionary.
> Would I have to create a "RULE" or a "TRIGGER" to be certain that the
> wordid is existing in tbldictionary in whatever language.
>
> I have the idea that a trigger will not prevent the insertion, or did I
> not read well enough?

What you can do in an after trigger is test that the value exists in the
other table or raise an error (which is basically what the foreign key
triggers do).

There are some issues with writing your own, the first being that to get
full foreign key style semantics you need triggers on the referenced table
as well, however if removing or updating the wordid in tbldictionary is
uncommon, you can probably avoid it.



view thread (3+ messages)  latest in thread

Message-ID: <20050607065228.O97782@megazone.bigpanda.com>
Permalink:  ../20050607065228.O97782@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20050607065228.O97782@megazone.bigpanda.com

 · 

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: sszabo@megazone.bigpanda.com, mlange@dltmedia.nl
  Subject: Re: rule or trigger?
  In-Reply-To: <20050607065228.O97782@megazone.bigpanda.com>

* 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