Re: 3 foreign keys in 1 table for 3 1-to-many relations? - Mailing list pgsql-sql

From David G. Johnston
Subject Re: 3 foreign keys in 1 table for 3 1-to-many relations?
Date
Msg-id CAKFQuwbnXfCnGWh5MatiY3QEkC5c86+VLXfdPRFyqrOXrqCq8A@mail.gmail.com
Whole thread Raw
In response to 3 foreign keys in 1 table for 3 1-to-many relations?  (gvim <gvimrc@gmail.com>)
List pgsql-sql
On Wed, Jun 17, 2015 at 8:51 PM, gvim <gvimrc@gmail.com> wrote:
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.

You should probably take a look at inheritance and see if it can accommodate your use case.


David J​

pgsql-sql by date:

Previous
From: gvim
Date:
Subject: 3 foreign keys in 1 table for 3 1-to-many relations?
Next
From: Marc Mamin
Date:
Subject: Re: self join issue