pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ries van Twisk <ries@jongert.nl>
To: pgsql-sql@postgresql.org
Subject: Dublicates pairs in a table.
Date: Mon, 16 Sep 2002 16:51:23 +0200
Message-ID: <000201c25d90$87230c10$6500000a@IT000> (raw)

Dear guys/girls,

I have a small question which I could not clearly find in the postgreSQL
manual.

if I create this table and index
CRAEATE TABLE test (
	id	SERIAL,
	c1	VARCHAR(32),
	c2	VARCHAR(32),
	c3	VARCHAR(32)
);

CREATE UNIQUE INDEX test_idx ON test(id, c1,c2);

what I try to archive here is that I don't want duplicate pais in my table:
example

INSET INTO test (c1,c2) VALUES('a', 'a');	-- Allowed
INSET INTO test (c1,c2) VALUES('b', 'b');	-- Allowed
INSET INTO test (c1,c2) VALUES('b', 'c');	-- Allowed
INSET INTO test (c1,c2) VALUES('a', 'a');	-- Not allowed since we already
have a duplicate ('a', 'a') pair
INSET INTO test (c1,c2) VALUES('b', 'c');	-- Not allowed since we already
have a duplicate ('b', 'c') pair

etc. etc. I think you get the idea...

What I want to know is that if this is smart do do, or is there a other
better way to make sure I don't insert duplicate pairs in my database.
I'm not sure if a stored procedure is better in my case since I don't really
need the index on columns c1 or c2.
I'm looking for performance technical answers here thus speed vs memory
comparisons. Ofcourse a pointer to a URL will also do..

Best Regards,
Ries van Twisk










view thread (10+ messages)  latest in thread

Message-ID: <000201c25d90$87230c10$6500000a@IT000>
Permalink:  ../000201c25d90$87230c10$6500000a@IT000/
Also on:    postgresql.org/message-id/000201c25d90$87230c10$6500000a@IT000

 · 

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: ries@jongert.nl
  Subject: Re: Dublicates pairs in a table.
  In-Reply-To: <000201c25d90$87230c10$6500000a@IT000>

* 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