From: | "Rodrigo Sakai" <rodrigo(dot)sakai(at)zanthus(dot)com(dot)br> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Interval referential integrity |
Date: | 2006-10-19 10:51:17 |
Message-ID: | 002301c6f36c$83c26310$4700a8c0@TREEZANTHUS |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello all,
Im developing a specialist application that needs a different kind of
referential integrity! I need interval referential integrity where the
bounds of the referenced interval must overlaps (or be equal) the bounds of
the referencing interval!
For example,
----------------------------------------------------------------------------
---------------------------------------------------------------
-- I did the functions IN and OUT to get this working
Create type t_interval (
Lower int,
Upper int
);
CREATE TABLE tableA (
tableA_id integer,
name varchar(30),
boundA t_interval,
constraint pk_tableA primary key (tableA, boundA)
);
CREATE TABLE tableB (
tableB_id integer,
boundB t_interval,
constraint fk_B_A foreign key (tableB_id, boundB) references tableA
);
----------------------------------------------------------------------------
---------------------------------------------------------------
So, tableA.boundA OVERLAPS tableB.boundB!
Example,
Insert into tableA values (1, test 1, (1, 5));
Insert into tableB values (1, (2, 4)); --> POSSIBLE
Insert into tableB values (1, (1, 3)); --> POSSIBLE
Insert into tableB values (1, (3, 7)); --> NOT POSSIBLE
I know that I need to change some (may be a lot of) things in the source
code. Specifically in the RI_TRIGGER.C (isn´t???). But I need some help to
do this!
Anyone have an idea?
Thanks in advance!
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Kramer | 2006-10-19 11:13:31 | timestamp as primary key? |
Previous Message | Daniel.Chmielewski | 2006-10-19 09:49:23 | trigger postgresql 7.4 |