Foreign Exclusion Constraints

From: Nathan Boley <npboley(at)gmail(dot)com>
To: PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Foreign Exclusion Constraints
Date: 2013-02-20 22:34:20
Message-ID: CAHetpQQK_EbQ-AbH9SVNaXy4gJyaajQjxfad2x+u5GBMqAzt7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi All,

I have tables:

CREATE TABLE chromosomes (
id varchar(10) PRIMARY KEY,
location int4range
);

CREATE TABLE exons (
chromosome varchar(10) REFERENCES chromosomes(id),
strand varchar(1),
location int4range
);

I'm trying to store exons that must fit within a chromosome, but the
chromosomes all have different lengths, so I want a check constraint
so that location is contained within CHR_RANGE where CHR_RANGE is
taken from the chromosomes table.

ie, it would be something like:

FOREIGN KEY (chromosome) REFERENCES chromosomes(chromosome) USING gist
(during WITH <@ )

Can I add that constraint without a trigger?

The archives seem to say no, but I thought I'd ask...

http://www.postgresql.org/message-id/1288033876.6278.6.camel@vanquo.pezone.net
http://www.postgresql.org/message-id/CACECd8i4P4iNqUii4Lqsw0qSthawhh3gE=AtmBDSJN25qrx15g@mail.gmail.com
http://www.postgresql.org/message-id/1678334.8llTyI05Te@hek506

Thanks,
Nathan Boley

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Toby Corkindale 2013-02-20 23:21:47 Re: Perl function leading to out of memory error
Previous Message Alban Hertroys 2013-02-20 19:24:18 Re: How to remove an item from integer array type