Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6EA624763B7 for ; Mon, 16 Sep 2002 10:52:32 -0400 (EDT) Received: from sv003.int.jongert.nl (jongert.nl [194.109.59.87]) by postgresql.org (Postfix) with ESMTP id 22BB04763B0 for ; Mon, 16 Sep 2002 10:52:31 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by sv003.int.jongert.nl (Postfix) with SMTP id 651393C3; Mon, 16 Sep 2002 16:50:29 +0200 (CEST) Received: from IT000 (IT000.int.jongert.nl [10.0.0.101]) by sv003.int.jongert.nl (Postfix) with SMTP id C62413A2 for ; Mon, 16 Sep 2002 16:50:28 +0200 (CEST) Reply-To: From: "Ries van Twisk" To: Subject: Dublicates pairs in a table. Date: Mon, 16 Sep 2002 16:51:23 +0200 Message-ID: <000201c25d90$87230c10$6500000a@IT000> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/176 X-Sequence-Number: 9453 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