Re: [GENERAL] string primary key

2006-05-12 Thread Martin Kuria
] ++ From: Bruno Wolff III <[EMAIL PROTECTED]> To: Mark Gibson <[EMAIL PROTECTED]> CC: pgsql-general@postgresql.org Subject: Re: [GENERAL] string primary key Date: Fri, 12 May 2006 01:54:17 -0500 On Thu, May 11, 2006 at 09:52:41 -

Re: [GENERAL] string primary key

2006-05-12 Thread Bruno Wolff III
On Thu, May 11, 2006 at 10:43:50 -0600, Mark Gibson <[EMAIL PROTECTED]> wrote: > > I've got a followup - The primary key for the table in question consists > of 2 varchar fields: picture 'state' and 'city' where city is guaranteed > to be unique within a state, and (state, city) form a unique

Re: [GENERAL] string primary key

2006-05-11 Thread Bruno Wolff III
On Thu, May 11, 2006 at 09:52:41 -0600, Mark Gibson <[EMAIL PROTECTED]> wrote: > Is there a disadvantage to having the primary key for a table be a text > type vs. an integer type? Performance? Any difference between having a > varchar or char as a primary key? You probably want to use 'text

Re: [GENERAL] string primary key

2006-05-11 Thread Scott Marlowe
On Thu, 2006-05-11 at 11:43, Mark Gibson wrote: > Scott Marlowe wrote: > > > > > If you need a unique constraint on the text field anyway, and it's a > > natural key, you're generally better of using that field as the pk. > > > > However, if it's not a natually unique key, then it shouldn't be t

Re: [GENERAL] string primary key

2006-05-11 Thread Mark Gibson
Scott Marlowe wrote: If you need a unique constraint on the text field anyway, and it's a natural key, you're generally better of using that field as the pk. However, if it's not a natually unique key, then it shouldn't be the pk, and int is a perhaps better choice. There are two VERY opposit

Re: [GENERAL] string primary key

2006-05-11 Thread Scott Marlowe
On Thu, 2006-05-11 at 10:52, Mark Gibson wrote: > Is there a disadvantage to having the primary key for a table be a text > type vs. an integer type? Performance? Any difference between having a > varchar or char as a primary key? > > My instinct tells me that an integer is preferred, but I'm

[GENERAL] string primary key

2006-05-11 Thread Mark Gibson
Is there a disadvantage to having the primary key for a table be a text type vs. an integer type? Performance? Any difference between having a varchar or char as a primary key? My instinct tells me that an integer is preferred, but I'm looking for a more concrete answer. Thanks, Mark