From: | John McCawley <nospam(at)hardgeus(dot)com> |
---|---|
To: | Joost Kraaijeveld <J(dot)Kraaijeveld(at)Askesis(dot)nl> |
Cc: | "Pgsql-sql(at)postgresql(dot)org" <Pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Foreign key to 2 tables problem |
Date: | 2005-11-22 15:37:33 |
Message-ID: | 43833B3D.2020407@hardgeus.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I've never seen anything like that. I'm sure it's conceivable that you
could write a weird trigger for it, but you have to consider
maintainability, and what your queries are going to look like. I
haven't seen your datamodel, but it would seem that you could accomplish
what you're looking for by having two separate foriegn key columns in
the bankaccount table, one for the customer and one for the supplier.
While your queries may end up somewhat funky, I can't imagine they'd be
any worse than what would occur with what you're suggesting.
However, if customers or suppliers can have multiple accounts, you are
going to need an intermediate table, as suggested by Neil.
Joost Kraaijeveld wrote:
>Hi,
>
>Is there a way to create a foreign key to 2 tables: e.g. a bankaccount
>table that has a column "owner", that must point to a record in either
>the customer or the supplier table?
>
>
>TIA
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Rod Taylor | 2005-11-22 15:39:56 | Re: Foreign key to 2 tables problem |
Previous Message | Neil Saunders | 2005-11-22 15:31:07 | Re: Foreign key to 2 tables problem |