X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8861C4762F6 for ; Mon, 7 Apr 2003 12:48:54 -0400 (EDT) Received: from nat.inquent.com (unknown [216.208.117.7]) by postgresql.org (Postfix) with ESMTP id 70B624762E1 for ; Mon, 7 Apr 2003 12:48:53 -0400 (EDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by nat.inquent.com (8.12.8p1/8.12.8) with ESMTP id h37GmvSY084265; Mon, 7 Apr 2003 12:48:58 -0400 (EDT) (envelope-from rbt@rbt.ca) Subject: Re: Creating a foreign key on the Union of two tables From: Rod Taylor To: Saad Saeed Cc: pgsql-sql@postgresql.org In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-DCNH4HKaS+AAG/NTYRZ/" Organization: Message-Id: <1049734135.40144.17.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 07 Apr 2003 12:48:56 -0400 X-Spam-Status: No, hits=-44.3 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/100 X-Sequence-Number: 12801 --=-DCNH4HKaS+AAG/NTYRZ/ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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. --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-DCNH4HKaS+AAG/NTYRZ/ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+kav36DETLow6vwwRAq0zAJ412ES/Pxiqm3zGF3NNrH3y6/I1SwCfUyjv 0or8AVGM+ZytJvqXvmTybm8= =6OL6 -----END PGP SIGNATURE----- --=-DCNH4HKaS+AAG/NTYRZ/--