Re: Re: 7.1.2 ERROR: UNIQUE constraint matching given keys for referenced table ......

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: eddie iannuccelli <eddie(dot)iannuccelli(at)toulouse(dot)inra(dot)fr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: 7.1.2 ERROR: UNIQUE constraint matching given keys for referenced table ......
Date: 2001-07-05 16:57:52
Message-ID: Pine.BSF.4.21.0107050953170.69990-100000@megazone23.bigpanda.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thu, 5 Jul 2001, eddie iannuccelli wrote:

> Regrading your discussion, at the end, what is the difference between a
> REFERENCE clause in a field definition and a FOREIGN KEY in the table
> definition ? What is the best solution to implement a classical foreign
> key in a table ?

"If a <column constraint definition> is specified that contains a
<references specification>, then it is equivalent to a <table constraint
definition> that contains the followin g<table constraint>:
CND FOREIGN KEY (C) <references specification> CA"

The only major difference that you generally have to worry about is
that table FOREIGN KEY constraints allow you to have multiple column
key references. It's similar to the difference between the column
and table level PRIMARY KEY specifications.

Generally I personally use the column level one for single column
keys and only use the table one for multiple column keys although that's
mostly a matter of style. I'm sure there are people that use the
table one for everything.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ligia Pimentel 2001-07-05 17:28:32 Problem with postgres user
Previous Message Chuck Shunk 2001-07-05 16:50:40 Re: Remote queries