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: 8831.1083374025@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message FL 2004-05-01 10:06:01 unsubscribe
Previous Message Sean Shanny 2004-05-01 00:08:12 Re: "out of memory" error