X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EBF8CD1B518 for ; Fri, 19 Dec 2003 00:24:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 10795-03 for ; Thu, 18 Dec 2003 20:23:24 -0400 (AST) Received: from mx1.zetec.com (mx1.zetec.com [209.43.175.49]) by svr1.postgresql.org (Postfix) with ESMTP id 45867D1B513 for ; Thu, 18 Dec 2003 20:23:20 -0400 (AST) Received: from exchange02.zetec.com (Not Verified[209.43.175.46]) by mx1.zetec.com id ; Thu, 18 Dec 2003 16:26:25 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Subject: INDEX and NULL values Date: Thu, 18 Dec 2003 16:23:21 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: INDEX and NULL values Thread-Index: AcPFxk8MMMGt+q4hTrGhLrKsVd4ASQ== From: "Matthew Rudolph" To: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/150 X-Sequence-Number: 16316 Here are the sample tables for my question. CREATE TABLE bar ( id int2 PRIMARY KEY UNIQUE DEFAULT nextval('bar_id_seq'), ... ); CREATE TABLE foo ( id int2 PRIMARY KEY UNIQUE DEFAULT nextval('foo_id_seq'), number int2 NOT NULL, bar_id int2 REFERENCES bar ON UPDATE CASCADE ON DELETE CASCADE, ... ); CREATE UNIQUE INDEX foo_number_id_index ON foo(number, bar_id); I am a novice for sure. I am trying to prevent multiple combinations of the number and bar_id fields. However, since the bar_id can be NULL I am actually getting multiple combinations with NULL.=20 For example,=20 foo: id number bar_id ..... ------------------------------- 1 | 1 |=20 2 | 2 | 3 3 | 1 |=20=20=20 .... Row 1 and 3 are duplicates that I wish to disallow. I am however seeing just this behavior with 7.3.2. I am seeing the duplicates. I am not able to add another row with number =3D 2 and bar_id =3D 3.=20 What am I doing wrong? What sort of NULLism is biting me? I have searched around the lists and the documentation, I am sure it is explained but I am not able to see the solution. I link that helps out would be appreciated. Thanks for your help. Matthew ----------------------------------------------------------------------- DISCLAIMER: Information contained in this message and/or attachment(s) may contain confidential information of Zetec, Inc. If you have received this transmission in error, please notify the sender by return email. -----------------------------------------------------------------------