Re: select based on multi-column primary keys

From: "codeWarrior" <gpatnude(at)hotmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: select based on multi-column primary keys
Date: 2007-01-23 21:07:19
Message-ID: ep5t77$oqt$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

No... its a table constraint using a unique, implicit index on the listed
columns. .

PRIMARY KEY ( column [, ...] )

The PRIMARY KEY table constraint is similar to the PRIMARY KEY column
constraint. As a table constraint, PRIMARY KEY allows multiple columns to be
defined in a parenthetical expression, separated by commas. An implicit
index will be created across columns. The combination of values for each
column specified must therefore amount to only unique and non-NULL values,
as with the PRIMARY KEY column constraint.

hehehe....

"Andrew Sullivan" <ajs(at)crankycanuck(dot)ca> wrote in message
news:20070121152838(dot)GB3533(at)phlogiston(dot)dyndns(dot)org(dot)(dot)(dot)
> On Fri, Jan 19, 2007 at 07:45:40PM -0800, codeWarrior wrote:
>> AFAIK: You cannot have multiple primary keys. How would you know which
>> one
>> is the actual key ?
>
> You can have a multi-column primary key, though. That's a perfectly
> legitimate approach.
>
>> FYI: What you are really talking about are table contraints... When you
>> have
>
> No, it's a multi-column primary key.
>
>> My advice would be to alter your table structure so that you have a
>> "real"
>> PK not table constraints -- that would make it searchable....
>
> This is already searchable. What you are talking about is not a real
> primary key, but an artificial one. The OP already has a real
> primary key. SQL purists think artificial primary keys mean that you
> haven't done enough normalisation. I'm going to remain silent on
> that topic, though, so that we don't get a Thread That Does Not End
> :)
>
> A
>
>
> --
> Andrew Sullivan | ajs(at)crankycanuck(dot)ca
> If they don't do anything, we don't need their acronym.
> --Josh Hamilton, on the US FEMA
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2007-01-23 21:26:28 Re: select based on multi-column primary keys
Previous Message Oisin Glynn 2007-01-23 14:52:50 Re: Odbc configuration on Localhost