Re: Constraint Trigger's referenced_table - Mailing list pgsql-general

From Richard Broersma Jr
Subject Re: Constraint Trigger's referenced_table
Date
Msg-id 383573.85613.qm@web31804.mail.mud.yahoo.com
Whole thread Raw
In response to Re: Constraint Trigger's referenced_table  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Constraint Trigger's referenced_table
List pgsql-general
--- On Sat, 12/22/07, Tom Lane <tgl@sss.pgh.pa.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
hasrecords 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
designedto 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
implementedin 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
CREATEConstraint Trigger enable this kind of notification to perform cross checking even though there are strictly no
pk/fkrelations between these table? 

Regards,
Richard Broersma Jr.

pgsql-general by date:

Previous
From: Richard Broersma Jr
Date:
Subject: Re: Constraint Trigger's referenced_table
Next
From: Martijn van Oosterhout
Date:
Subject: Re: update pg question?