Foreign Key with an "OR" condition (and two concatenated columns)?

From: Phoenix Kiula <phoenix(dot)kiula(at)gmail(dot)com>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Foreign Key with an "OR" condition (and two concatenated columns)?
Date: 2012-01-08 14:33:43
Message-ID: CAFWfU=unSzH+WkPtxNjCKH3ZcHQsYER3py1WEGnMNtfNSDA4TA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi. Hope I'm articulating the question correctly.

I currently have a foreign key like this:

"fk_table2" FOREIGN KEY (id) REFERENCES table1(id) ON DELETE CASCADE;

Given the peculiar needs of this db, it seems that in some cases we
will need to track the "id" of table2 against a concatenation of two
columns in table2. So in pseudocode, it would look something like
this.

"fk_table2" FOREIGN KEY (id) REFERENCES table1(id OR
id||'.'||column2) ON DELETE CASCADE;

Do I need a separate constraint for this?

Many thanks for any pointers!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2012-01-08 16:58:49 Re: Foreign Key with an "OR" condition (and two concatenated columns)?
Previous Message Alban Hertroys 2012-01-08 12:58:47 Re: JOIN column maximum