Skip site navigation (1) Skip section navigation (2)

Re: One or Both Foregin Keys

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dennis Gearon <gearond(at)fireserve(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: One or Both Foregin Keys
Date: 2004-05-01 01:13:45
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Dennis Gearon <gearond(at)fireserve(dot)net> writes:
> I am working on a design where a location for something can have:
>     Fully qualified address with even building names, room numbers, and 
> booth numbers.
> **-OR-**
>     GPS location
> **-OR-**
>     Both

> Other than triggers, is there a way to enforce this using tables and 
> primary keys?

Put foreign key constraints on the address and GPS loc (so that they
must be either valid or NULL) and then add a CHECK constraint saying
they can't both be NULL.

			regards, tom lane

In response to


pgsql-general by date

Next:From: FLDate: 2004-05-01 10:06:01
Subject: unsubscribe
Previous:From: Sean ShannyDate: 2004-05-01 00:08:12
Subject: Re: "out of memory" error

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group