Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is

2005-04-28 Thread Ron Mayer
Marco Colombo wrote: That is, given a variable A, you can always write a boolean expression that evaluates True or False to test if A is _equal_ to None/undef/NULL (in C): And of course you can do this in SQL as well. ('a', NULL) is neither the same _nor different_ from ('a', 2). Uh, I'm not sure w

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-28 Thread Stephane Bortzmeyer
On Thu, Apr 28, 2005 at 02:04:29PM +0200, Marco Colombo <[EMAIL PROTECTED]> wrote a message of 146 lines which said: > No. NULL is NOT 'None', nor 'undef', and definitely not NULL as in > C. Thanks for the very good and detailed explanation of NULL in SQL. Curious people may note that the stra

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is

2005-04-28 Thread Marco Colombo
On Wed, 2005-04-27 at 17:00 +0200, Stephane Bortzmeyer wrote: > On Wed, Apr 27, 2005 at 09:36:57AM -0500, > Scott Marlowe <[EMAIL PROTECTED]> wrote > a message of 18 lines which said: > > > Often the best bet here, btw, is to declare it not null then use > > something other than null to represe

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-27 Thread Stephane Bortzmeyer
On Wed, Apr 27, 2005 at 05:04:07PM +0200, Sebastian Böck <[EMAIL PROTECTED]> wrote a message of 24 lines which said: One is enough :-) v > CREATE TABLE table x ( > name TEXT NOT NULL, > address INET > ); > > CREATE UNIQUE INDEX na ON x (name, address); > C

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-27 Thread Stephane Bortzmeyer
On Wed, Apr 27, 2005 at 09:36:57AM -0500, Scott Marlowe <[EMAIL PROTECTED]> wrote a message of 18 lines which said: > Often the best bet here, btw, is to declare it not null then use > something other than null to represent null, like the text > characters NA or something. Yes, but it defeats

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-27 Thread Stephane Bortzmeyer
On Wed, Apr 27, 2005 at 04:50:23PM +0200, Sebastian Böck <[EMAIL PROTECTED]> wrote a message of 48 lines which said: > CREATE UNIQUE INDEX na ON x (name, address) WHERE address IS NULL; No, because it prevents two tuples with the same value of "name". ---(end of broadc

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-27 Thread Tom Lane
Stephane Bortzmeyer <[EMAIL PROTECTED]> writes: > Yes, PostgreSQL is right and implement the standard. Now, what's the > rationale for the standard? I understand it for a single column but, > for several columns, it should be still possible to have different > tuples, such as (3, NULL) and (5, NULL

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-27 Thread Stephane Bortzmeyer
On Wed, Apr 27, 2005 at 10:26:30AM -0400, Tom Lane <[EMAIL PROTECTED]> wrote a message of 9 lines which said: > If that's what you want, declare it as UNIQUE not PRIMARY KEY. As shown by Patrick TJ McPhee, it does not work: tests=> create table x ( tests(>name TEXT NOT NULL, tests(>a

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-27 Thread Stephane Bortzmeyer
On Wed, Apr 27, 2005 at 05:19:32AM +, Patrick TJ McPhee <[EMAIL PROTECTED]> wrote a message of 37 lines which said: > but you should know that in SQL, unique constraints don't apply to > rows containing null values May be I should but I didn't. > your table definition will be as you want

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is

2005-04-27 Thread Scott Marlowe
On Wed, 2005-04-27 at 02:12, Stephane Bortzmeyer wrote: > On Tue, Apr 26, 2005 at 03:48:44PM -0500, > Scott Marlowe <[EMAIL PROTECTED]> wrote > a message of 26 lines which said: > > > Here's a quote from the SQL1992 spec that's VERY clear: > > Yes, PostgreSQL is right and implement the standar

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-27 Thread Patrick TJ McPhee
In article <[EMAIL PROTECTED]>, Stephane Bortzmeyer <[EMAIL PROTECTED]> wrote: % But it does not apply to primary keys containing a group of % columns. In that case (my case), columns do not have to be UNIQUE. But % they have to be NOT NULL, which puzzles me. It does apply to primary keys contain

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-27 Thread Stephane Bortzmeyer
On Tue, Apr 26, 2005 at 03:48:44PM -0500, Scott Marlowe <[EMAIL PROTECTED]> wrote a message of 26 lines which said: > Here's a quote from the SQL1992 spec that's VERY clear: Yes, PostgreSQL is right and implement the standard. Now, what's the rationale for the standard? I understand it for a s

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT

2005-04-26 Thread Stephane Bortzmeyer
On Tue, Apr 26, 2005 at 03:22:40PM -0500, Guy Rouillier <[EMAIL PROTECTED]> wrote a message of 37 lines which said: > "The primary key constraint specifies that a column or columns of a > table may contain only unique (non-duplicate), nonnull values. > Technically, PRIMARY KEY is merely a combi

Re: [GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT NULL?

2005-04-26 Thread Guy Rouillier
Stephane Bortzmeyer wrote: > If I define a primary key: > >name TEXT NOT NULL, >address INET, >PRIMARY KEY(name, address) > > the definition (seen by \d) becomes: > > name | text| not null > address | inet|

[GENERAL] PRIMARY KEY on a *group* of columns imply that each column is NOT NULL?

2005-04-26 Thread Stephane Bortzmeyer
If I define a primary key: name TEXT NOT NULL, address INET, PRIMARY KEY(name, address) the definition (seen by \d) becomes: name | text| not null address | inet| not null "address" is now not null, which I d