Skip site navigation (1) Skip section navigation (2)

Re: Primary/Foreign Keys

From: Dante torio <dantorio_ayn(at)hotmail(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Primary/Foreign Keys
Date: 2009-05-15 12:33:48
Message-ID: SNT103-W203E365010ACA7E2894D07E25F0@phx.gbl (view raw or flat)
Thread:
Lists: pgsql-novice
Hi,

I am a novice PG user. I would like to know which among
these data types are best suited to be used as Primary/Foreign Keys. Some of my
assessment follows;

SERIAL autonumber.  

auto generated in postgres, but not when you use ODBC (i.e. MS Access as a frontend). When using it in another table as foreign key
you have to know which number corresponds to which. Once the sequence
is accidentally altered, an extra manipulation is needed (setval, etc)

INTEGER

More flexible than SERIAL autonumber but similarly you have to know the exact number in the parent table when filling the child table. Plus you enter the numbers manually.

VARCHAR/CHAR

use of codes alphanumeric is easier to remenber but some argues it will degrade query performance.

 Some expert advise please. If this is not the proper place to ask these questions then please point me to a proper
 forum.

Thanks

Dante
_________________________________________________________________
NEW! Get Windows Live FREE.
http://www.get.live.com/wl/all

pgsql-novice by date

Next:From: JanaDate: 2009-05-16 17:54:34
Subject: Custom sorting
Previous:From: A. KretschmerDate: 2009-05-15 11:52:03
Subject: Re: Transform table data

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group