Foriegn key to Union query or two tables

From: "Phillip J(dot) Allen" <paallen(at)attglobal(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Foriegn key to Union query or two tables
Date: 2003-02-19 18:05:04
Message-ID: 3E53C750.60804@attglobal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi all,

I have two tables 'composition_type' and 'mineral_type'. Both tables
have a number field for their primary key(comp_id & min_id) and their
primary keys are unique between the two tables. The third table is
'rock_sample' which has a column 'composition'. Now the
rock_sample.compsition column can be filled with a with either
compositon_type.comp_id or mineral_type.min_id. So how can I create a
foreign key for rock_samp.composition referencing
composition_type.comp_id AND mineral_type.min_id?

I know some might/will say why are the two tables not just merged into
one but they are under normal circumstances two different things with
difference mutually exclusive attributes. Also in other situations I
need them appart.

Any suggestions? I just tried adding a foreign key referencing a VIEW
with a UNION query and psql just spit it back.

Thanks,

Phillip J. Allen
Consulting Geochemist/Geologist
Lima Peru
e-mail: paallen(at)attglobal(dot)net

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2003-02-19 18:45:04 Re: Foriegn key to Union query or two tables
Previous Message Adam Bultman 2003-02-19 15:31:45 Re: Importing Postgres 7.1.1 DBs into Postgres 7.3.2