From: | Rod Taylor <rbt(at)rbt(dot)ca> |
---|---|
To: | Saad Saeed <saads(at)umich(dot)edu> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Creating a foreign key on the Union of two tables |
Date: | 2003-04-07 16:48:56 |
Message-ID: | 1049734135.40144.17.camel@jester |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Sun, 2003-04-06 at 17:53, Saad Saeed wrote:
> I have 2 tables "A" and "B" in mySQL. They both have an attribute 'id'
> which is unique between the 2 tables. I want the union of these 2
> attributes to be a foreign key in a 3rd table "C". How do I specify
> this constraing in sql (mySQL) in table C? And for complex reasons I
> cannot merge the 2 tables A and B.
Can't say for MySQL (since this is a PostgreSQL list!!!!!), but creating
a foreign key like that to 2 different tables is against spec because
one cannot create a unique constraint across 2 tables.
That said, you could create a set of pl/pgsql functions that can imitate
what a foreign key does and will work in the situation you describe --
if you're using PostgreSQL.
--
Rod Taylor <rbt(at)rbt(dot)ca>
PGP Key: http://www.rbt.ca/rbtpub.asc
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-04-07 16:50:30 | Re: Creating a foreign key on the Union of two tables |
Previous Message | David Olbersen | 2003-04-07 16:33:36 | Re: Difficult query (for me) |