logo       

Foriegn key to Union query or two tables: msg#00237

db.postgresql.novice

Subject: Foriegn key to Union query or two tables

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@xxxxxxxxxxxxx



---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise