| From: | Jason Burke <jbd2050(at)saintjoe(dot)edu> | 
|---|---|
| To: | PSQL Mailing List <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Multiple Foreign Keys | 
| Date: | 2000-11-17 15:44:53 | 
| Message-ID: | 3A155275.BDE0662F@saintjoe.edu | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
I was wondering if there is any way to set up a foreign key that is
valid not just if the value exists in one table but if it exists in any
of 3 tables.  Here is what I mean.  I have a sequence called 'id_number'
that I start at 1 and increment by 1 every time its used.  I then have 3
tables each of which has an id attribute the is set up like this:
id int PRIMARY KEY default nextval('id_number'),
My question is this.  I have a fourth table that also has an id field
but I want to constrain it so that it must be a valid id from either
table 1, or table 2, or table 3.  I cannot seem to set it up except for
making it be in all 3 which obviously could never happen.  I'd
appreciate any advice you could provide me in this regard.  Maybe it's
not possible, but if there is a way it would sure save a lot of hassle
in otherwise having to redesign the DB.
Thanks
jason j burke
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alfred Perlstein | 2000-11-17 16:01:35 | Re: What language | 
| Previous Message | Josh Berkus | 2000-11-17 15:40:22 | Re: Requests for Development |