Re: [SQL] surrogate vs natural primary keys

2008-09-18 Thread Steve Midgley
At 08:20 AM 9/18/2008, [EMAIL PROTECTED] wrote: Message-ID: <[EMAIL PROTECTED]> Date: Wed, 17 Sep 2008 09:20:44 -0700 From: "Richard Broersma" <[EMAIL PROTECTED]> To: "Scott Marlowe" <[EMAIL PROTECTED]> Subject: Re: surrogate vs natural primary keys In-Reply-To: <[EMAIL PROTECTED]> References:

Re: [SQL] surrogate vs natural primary keys

2008-09-17 Thread Steve Midgley
To: pgsql-sql@postgresql.org From: Seb <[EMAIL PROTECTED]> Subject: Re: surrogate vs natural primary keys Date: Mon, 15 Sep 2008 17:56:31 -0500 Organization: Church of Emacs Lines: 20 Message-ID: <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> X-Archive-Numbe

Re: [SQL] surrogate vs natural primary keys

2008-09-17 Thread Richard Broersma
On Wed, Sep 17, 2008 at 7:45 AM, Scott Marlowe <[EMAIL PROTECTED]> wrote: >> CREATE TABLE t2 ( >>d1 varchar(200), >>d2 int8, >>d3 varchar(1000), >>PRIMARY KEY (d1, d2) >>FOREIGN KEY (d1, d2) REFERENCES t1(c1, c2) ); >> >> thereby avoiding repeating multiple pieces of >> informa

Re: [SQL] surrogate vs natural primary keys

2008-09-17 Thread Scott Marlowe
On Wed, Sep 17, 2008 at 7:20 AM, Seb <[EMAIL PROTECTED]> wrote: > On Tue, 16 Sep 2008 20:34:51 -0600, > "Scott Marlowe" <[EMAIL PROTECTED]> wrote: > > [...] > >> create table t2 ( >> d1 varchar(200), >> d2 int8, >> d3 varchar(1000), >> foreign key t2_fk references t1(c1,c2) ); > > T

Re: [SQL] surrogate vs natural primary keys

2008-09-17 Thread Seb
On Tue, 16 Sep 2008 20:34:51 -0600, "Scott Marlowe" <[EMAIL PROTECTED]> wrote: [...] > create table t2 ( > d1 varchar(200), > d2 int8, > d3 varchar(1000), > foreign key t2_fk references t1(c1,c2) ); Thanks Scott, I guess you meant: CREATE TABLE t2 ( d1 varchar(200), d2 i

Re: [SQL] surrogate vs natural primary keys

2008-09-16 Thread Scott Marlowe
On Tue, Sep 16, 2008 at 6:10 PM, Seb <[EMAIL PROTECTED]> wrote: > Hi, > > After some more reading and considering your feedback, I'm still > somewhat confused about this issue. > > 1. Should the choice of surrogate/natural primary keys be done across an > entire database, or does it make more sense

Re: [SQL] surrogate vs natural primary keys

2008-09-16 Thread Seb
Hi, After some more reading and considering your feedback, I'm still somewhat confused about this issue. 1. Should the choice of surrogate/natural primary keys be done across an entire database, or does it make more sense to do it on a per-table basis? I reckon one could do it on a per-table bas

Re: [SQL] surrogate vs natural primary keys

2008-09-16 Thread Andrew Sullivan
On Tue, Sep 16, 2008 at 07:59:20AM -0700, Richard Broersma wrote: > key. From my reading of some of the Celko books, he strongly ascribes > to codes as primary keys. His suggestion is to use internationally > recognized codes (if they exist) for identify items. The problem with that strategy is

Re: [SQL] surrogate vs natural primary keys

2008-09-16 Thread Richard Broersma
On Mon, Sep 15, 2008 at 3:45 PM, Scott Marlowe <[EMAIL PROTECTED]> wrote: > for > instance, when you book a flight with an airline, you'll get a locator > code like A89JK3 that is unique to any other locator code in the > system. Sure, you could make a natural key of first name, last name, > addre

Re: [SQL] surrogate vs natural primary keys

2008-09-15 Thread Seb
On Mon, 15 Sep 2008 16:45:08 -0600, "Scott Marlowe" <[EMAIL PROTECTED]> wrote: [...] > I think this question is a lot like "how large should I set > shared_buffers?" There's lots of different answers based on how you > are using your data. Yes, this is precisely what I'm after: *criteria* to he

Re: [SQL] surrogate vs natural primary keys

2008-09-15 Thread Scott Marlowe
On Mon, Sep 15, 2008 at 4:02 PM, Seb <[EMAIL PROTECTED]> wrote: > Hi, > > I've been reading several articles on this hotly debated issue and still > can't find proper criteria to select one or the other approach for the > database I'm currently designing. I'd appreciate any pointers. Thanks. You

[SQL] surrogate vs natural primary keys

2008-09-15 Thread Seb
Hi, I've been reading several articles on this hotly debated issue and still can't find proper criteria to select one or the other approach for the database I'm currently designing. I'd appreciate any pointers. Thanks. Cheers, -- Seb -- Sent via pgsql-sql mailing list (pgsql-sql@postgresq