Re: Constraint Trigger's referenced_table

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: General PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Constraint Trigger's referenced_table
Date: 2007-12-23 07:59:04
Message-ID: 383573.85613.qm@web31804.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- On Sat, 12/22/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> No, the purpose is to support foreign-key triggers. FK constraints are
> implemented via cooperating triggers on the two tables, and
> each trigger has to be able to look at the other table.

When you say "each trigger has to be able to look" do you mean that each trigger needs to be notified when other table has records that are inserted/updated/deleted?

>From what I gathered from the reading of ri_triggers.c, FWIU it seems that this kind of cross table checking is designed to seek out any FKs or PKs in the related table and then execute a validating query that compares the PK to FK.

Can this kind of cross checking still be implemented for temporal relations where foreign keys are not actually implemented in the "referencing" table.

For example I want to enforce the primary-relation's time range to always engulf the time range of the foreign-relation.:
PK timeline:

|---p1---|--p2--|-p3-|p4|---p5---|

FK timeline:
|-f1-|----f2----|--f3--|--f4--|

So if I INSERT/UPDATE/DELETE records to either table, would implementing the "FROM referenced_table" predicated of the CREATE Constraint Trigger enable this kind of notification to perform cross checking even though there are strictly no pk/fk relations between these table?

Regards,
Richard Broersma Jr.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-12-23 10:38:21 Re: update pg question?
Previous Message Richard Broersma Jr 2007-12-22 22:15:13 Re: Constraint Trigger's referenced_table