Re: Foreign key to 2 tables problem
От | John McCawley |
---|---|
Тема | Re: Foreign key to 2 tables problem |
Дата | |
Msg-id | 43833B3D.2020407@hardgeus.com обсуждение исходный текст |
Ответ на | Foreign key to 2 tables problem (Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>) |
Ответы |
Re: Foreign key to 2 tables problem
|
Список | 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 > > >
В списке pgsql-sql по дате отправления: