X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 079A89FA5DC for ; Thu, 1 Jun 2006 08:07:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 83888-06 for ; Thu, 1 Jun 2006 08:07:04 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by postgresql.org (Postfix) with ESMTP id 849799FA040 for ; Thu, 1 Jun 2006 08:07:04 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id p48so386902nfa for ; Thu, 01 Jun 2006 04:07:02 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=t+jY3Rdhr5XaOxTSKbN5qBP7Afh/eViHpjVrgQ0e/Ebv5Z1ojuRxG3tFYxBgsvhNcdu1X+UJhQ5yfHnuH52z1bpqZXWkHnrB8JjO6/zA8rWTT+UGRs79fJq+96ctnZVtcBb9J87EifX2yTw6Lm8DL4hpM/erYiIQTUfq2a55Smw= Received: by 10.48.48.12 with SMTP id v12mr260054nfv; Thu, 01 Jun 2006 04:05:55 -0700 (PDT) Received: by 10.67.27.9 with HTTP; Thu, 1 Jun 2006 04:05:54 -0700 (PDT) Message-ID: <12b7ac1e0606010405u6e062f71mf4adbaeb6c46df5f@mail.gmail.com> Date: Thu, 1 Jun 2006 23:05:54 +1200 From: "David Clarke" To: pgsql-sql@postgresql.org Subject: Table design question MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/1 X-Sequence-Number: 25237 I'm reading Joe Celko's book SQL Programming Style for the second time and although I've been an OO developer for quite a few years I'm fairly green wrt SQL. Joe is obviously something of a curmudgeon and I would fall squarely into his newbie OO developer ordinal scale and I'm trying to avoid the slide into stupid newbie OO developer. So I'm designing a table and I'm looking for an appropriate key. The natural key is a string from a few characters up to a maximum of perhaps 100. Joe gets quite fierce about avoiding the use of a serial id column as a key. The string is unique in the table and fits the criteria for a key. So should I follow Joe's advice and use my natural key as the primary key? It sounds reasonable but it will mean at least one other table will have the string as a foreign key. My postgres intro book has id columns all over the place but is it really that big an issue these days to have a 100 character primary key? Are there postgres-specific implications for either approach? Thanks Dave