Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z5O3Z-00020E-LP for pgsql-sql@arkaria.postgresql.org; Thu, 18 Jun 2015 00:51:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z5O3Z-0002Oa-2k for pgsql-sql@arkaria.postgresql.org; Thu, 18 Jun 2015 00:51:49 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z5O3Y-0002OU-CX for pgsql-sql@postgresql.org; Thu, 18 Jun 2015 00:51:48 +0000 Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z5O3W-00054H-1s for pgsql-sql@postgresql.org; Thu, 18 Jun 2015 00:51:47 +0000 Received: by wicnd19 with SMTP id nd19so45079317wic.1 for ; Wed, 17 Jun 2015 17:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=Bu2uWEBNQC7LV3+E9f9kfPaAUucJ6qb4p0leU3L5C7E=; b=xBeqAYAqLA7aOSQ1JeKbjh2q4pn5mQFYp1/WdAqjt7J9DXD8R9N8BGRS02xNoF5Ghm jfUPeOMIY1theKeif0GWACMDQ3RIya3ZhFm4yvHwo9iEWQrA4lX8bkjqaDrf427bI7r0 gCTnx4T9R3g4JYPYWcEwK+uBpfFK4+TeDTWeX6z69kk45JeSpEyg3wHnZ0XCB6Cv4d6P /Y7zql+GIdIlseKienacG1OISm66WOiX3NYqala1v5aFEN9i6BEuteTkNE0BuEFtv6N4 GRa46PV+veebovVX7Lq6fZb7XXiK442zewoFzjPRLClkEz6l8nQWYcB/US0a5+rsmHGi NtPw== X-Received: by 10.181.27.131 with SMTP id jg3mr58202371wid.89.1434588704617; Wed, 17 Jun 2015 17:51:44 -0700 (PDT) Received: from mac.local (heaton.plus.com. [212.159.45.120]) by mx.google.com with ESMTPSA id ez19sm28658607wid.19.2015.06.17.17.51.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jun 2015 17:51:43 -0700 (PDT) Message-ID: <5582161F.7070809@gmail.com> Date: Thu, 18 Jun 2015 01:51:43 +0100 From: gvim User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: 3 foreign keys in 1 table for 3 1-to-many relations? Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org I have 3 tables A, B & C each of which has a 1-to-many relation with a Comments table but I can't fathom how to set up the foreign key(s) in Comments without resorting to distinct A_id, B_id & C_id columns in Comments and enforcing 2 of the 3 columns be NULL for a given row. Seems ugly. gvim -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql