From: Reece Hart <reece@in-machina.com>
To: Jodi Kanter <jkanter@virginia.edu>
Cc: Postgres Admin List <pgsql-admin@postgresql.org>
Subject: Re: no dup rows
Date: Mon, 02 Aug 2004 12:09:52 -0700
Message-ID: <1091473791.16547.89.camel@tallac> (raw)
In-Reply-To: <410E88D6.8050906@virginia.edu>
References: <410E88D6.8050906@virginia.edu>
On Mon, 2004-08-02 at 11:32, Jodi Kanter wrote:
> I have a linking table that has only two fields in it and both are
> foreign keys to other tables. I'd like to ensure that there are never
> any duplicate rows in this table. I was planning on creating a
> multi-column unique index to satisfy this requirement. Is there a more
> appropriate way to accomplish this or am I on the right track?>
Yep, that is the correct way to impose this constraint.
I give constraints meaningful names prefixed by the table name (e.g.,
tablename_seq_already_in_set) so that the cause of an error is more
readily identifiable. This is particularly useful for insertions into
complex tables with multiple constraints.
-Reece
--
Reece Hart, Ph.D. rkh@gene.com, http://www.gene.com/
Genentech, Inc. 650-225-6133 (voice), -5389 (fax)
Bioinformatics and Protein Engineering
1 DNA Way, MS-93 http://www.in-machina.com/~reece/
S. San Francisco, CA 94080-4990 reece@in-machina.com, GPG: 0x25EC91A0
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: reece@in-machina.com, jkanter@virginia.edu
Subject: Re: no dup rows
In-Reply-To: <1091473791.16547.89.camel@tallac>
References: <410E88D6.8050906@virginia.edu> <1091473791.16547.89.camel@tallac>
* 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