pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Josh Berkus <josh@agliodbs.com>
Cc: Jan Wieck <JanWieck@Yahoo.com>
Cc: Markus Bertheau <twanger@bluetwanger.de>
Cc: olly@lfix.co.uk
Cc: pgsql-sql@postgresql.org
Subject: Re: multi column foreign key for implicitly unique columns
Date: Wed, 18 Aug 2004 10:45:35 -0700 (PDT)
Message-ID: <20040818104151.Y6662@megazone.bigpanda.com> (raw)
In-Reply-To: <200408181005.13230.josh@agliodbs.com>
References: <1092734724.2627.4.camel@dicaprio.akademie1.de>
	<200408171945.15663.josh@agliodbs.com>
	<41235A90.1080300@Yahoo.com>
	<200408181005.13230.josh@agliodbs.com>


On Wed, 18 Aug 2004, Josh Berkus wrote:

> >      In the case that a table constraint is a referential constraint,
> >      the table is referred to as the referencing table. The referenced
> >      columns of a referential constraint shall be the unique columns of
> >      some unique constraint of the referenced table.
>
> Missed that one.  Interesting.  AFAIK, the uniqueness of referenced columns is
> NOT a requirement of Relaitonal Algebra.   So why does SQL require it?
>
> Maybe I'll ask Joe Celko after he finishes moving to Austin.
>
> I have my own issue that forced me to use triggers.   Given:
>
> table users (
> 	name
> 	login PK
> 	status
> 	etc. )
>
> table status (
> 	status
> 	relation
> 	label
> 	definition
> 	PK status, relation )
>
> the relationship is:
> users.status = status.status AND status.relation = 'users';
>
> This is a mathematically definable constraint, but there is no way in standard
> SQL to create an FK for it.    This is one of the places I point to whenever
> we have the "SQL is imperfectly relational" discussion.

Well, I think SQL does give a way of specifying that constraint through
assertions and check constraints with subselects.  We just don't support
either of those constructs.



view thread (38+ messages)  latest in thread

Message-ID: <20040818104151.Y6662@megazone.bigpanda.com>
Permalink:  ../20040818104151.Y6662@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20040818104151.Y6662@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, josh@agliodbs.com, JanWieck@Yahoo.com, twanger@bluetwanger.de, olly@lfix.co.uk
  Subject: Re: multi column foreign key for implicitly unique columns
  In-Reply-To: <20040818104151.Y6662@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox