pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: 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:05:13 -0700
Message-ID: <200408181005.13230.josh@agliodbs.com> (raw)
In-Reply-To: <41235A90.1080300@Yahoo.com>
References: <1092734724.2627.4.camel@dicaprio.akademie1.de>
	<200408171945.15663.josh@agliodbs.com>
	<41235A90.1080300@Yahoo.com>

Jan,

>      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.	

-- 
Josh Berkus
Aglio Database Solutions
San Francisco



view thread (38+ messages)  latest in thread

Message-ID: <200408181005.13230.josh@agliodbs.com>
Permalink:  ../200408181005.13230.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200408181005.13230.josh@agliodbs.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: 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: <200408181005.13230.josh@agliodbs.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