Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id B523E9F9563 for ; Tue, 28 Aug 2007 12:35:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 60910-09 for ; Tue, 28 Aug 2007 12:35:31 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.237]) by postgresql.org (Postfix) with ESMTP id 38B1A9F949C for ; Tue, 28 Aug 2007 12:35:31 -0300 (ADT) Received: by nz-out-0506.google.com with SMTP id l8so1249651nzf for ; Tue, 28 Aug 2007 08:35:30 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=KGf0OOky9glFtEse1fd6Y9EGCBTJeNNW8mfXm5p4Qfvq1T6kwS9wWrLMk/NFRNF0tXyCjsUXVrAUkbhJu+kbIZTU4tzL8+BYux25zBN2o9iwbKo4Oxm8+r3zAtB8Hatl0H2W1echQiFdy4zBtfXkc30i4zHqogED7yCZlXpSRz4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=Yxma2c+oMWZCErxTLfSeyhrIxV5bUvLDfox908BsSUb8QFqWb+TpS2q4xticXHgSE81Qr9PFXpNM2CwsL6bIonJhUxwU2yBCJume4+EFQTwSDXCihcasb4bL3DyvMl/yOVniGGfJMv6xQKBpsYwTF4LIZsQPobv9f+2biDgCtt0= Received: by 10.140.165.21 with SMTP id n21mr2663884rve.1188315329582; Tue, 28 Aug 2007 08:35:29 -0700 (PDT) Received: by 10.141.40.8 with HTTP; Tue, 28 Aug 2007 08:35:29 -0700 (PDT) Message-ID: <99b656cb0708280835l4652bcfcje2c9a111a9a33d06@mail.gmail.com> Date: Tue, 28 Aug 2007 16:35:29 +0100 From: "Sebastian Ritter" To: pgsql-sql@postgresql.org Subject: Re: Database normalization In-Reply-To: <46D450A4.A3DD.0030.0@indicator.be> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_29470_22168674.1188315329734" References: <99b656cb0708210709j5182b73cna63a2d275efa0e84@mail.gmail.com> <99b656cb0708280737l3d50585fifcfef7103b26059b@mail.gmail.com> <46D450A4.A3DD.0030.0@indicator.be> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/246 X-Sequence-Number: 29184 ------=_Part_29470_22168674.1188315329734 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks guys, Sebastian On 8/28/07, Bart Degryse wrote: > > Im using Django as my Object relational Mapper so im pretty sure I > can not add a constraint such as ... > Then you should seriously consider changing your mapper. > > >>> "Sebastian Ritter" 2007-08-28 16:37 >>> > Thanks for the information. > > Both tables would be exactly sames apart from the foreign key relation to > clients or services. I agree that it seems strange to have one column that > is always null. Im using Django as my Object relational Mapper so im pretty > sure I can not add a constraint such as : CHECK constraint where !(col1 > IS NULL and col2 IS NULL). > > Another factor ive been considering is that one of the fields in this > table(s) definition(s) is free flowing text which could potentially become > very large. Should I take this in to > consideration when deciding whether to split the tables? In terms of > searching speed that is. > > Kindest regards. > Sebastian > > On 8/28/07, Andrew Sullivan wrote: > > > > On Tue, Aug 28, 2007 at 12:47:45PM +0100, Sebastian Ritter wrote: > > > > The update/message format is exactly the same for both. Should I > > make two > > > > different tables: > > > > > > one table with extra columns : is_client, client_id, service_id, > > where > > > > either client_id or service_id would be null depending on the > > is_client > > > > boolean? > > > > Is the rest of the data the same? If so, then one table is right. > > If not, then more than one table. In either case, I really hate the > > idea of two columns, one of which is always null. But if you're > > going to do that, make sure you add a CHECK constraint where !(col1 > > IS NULL and col2 IS NULL). > > > > A > > > > -- > > Andrew Sullivan | ajs@crankycanuck.ca > > I remember when computers were frustrating because they *did* exactly > > what > > you told them to. That actually seems sort of quaint now. > > --J.D. Baldwin > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 3: Have you checked our extensive FAQ? > > > > http://www.postgresql.org/docs/faq > > > > ------=_Part_29470_22168674.1188315329734 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks guys,

Sebastian

On 8/28/07, Bart Degryse <Bart.Degryse@indicator.be> wrote:
<quote>Im using Django as my Object relational Mapper so im pretty sure I can not add a constraint such as ...</quote>
Then you should seriously consider changing your mapper.

>>> "Sebastian Ritter" < ritter.sebastian@gmail.com> 2007-08-28 16:37 >>>

Thanks for the information.

Both tables would be exactly sames apart from the  foreign key relation to clients or services. I agree that it seems strange to have one column that is always null. Im using Django as my Object relational Mapper so im pretty sure I can not add a constraint such as : CHECK constraint where !(col1
IS NULL and col2 IS NULL).

Another factor ive been considering is that one of the fields in this table(s) definition(s) is free flowing text which could potentially become very large. Should I take this in to
consideration when deciding whether to split the tables? In terms of searching speed that is.

Kindest regards.
Sebastian

On 8/28/07, Andrew Sullivan <ajs@crankycanuck.ca > wrote:
On Tue, Aug 28, 2007 at 12:47:45PM +0100, Sebastian Ritter wrote:
> > The update/message format is exactly the same for both. Should I make two
> > different tables:

> >   one table with extra columns : is_client, client_id, service_id, where
> > either client_id or service_id would be null depending on the is_client
> > boolean?

Is the rest of the data the same?  If so, then one table is right.
If not, then more than one table.  In either case, I really hate the
idea of two columns, one of which is always null.  But if you're
going to do that, make sure you add a CHECK constraint where !(col1
IS NULL and col2 IS NULL).

A

--
Andrew Sullivan  | ajs@crankycanuck.ca
I remember when computers were frustrating because they *did* exactly what
you told them to.  That actually seems sort of quaint now.
                --J.D. Baldwin

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq


------=_Part_29470_22168674.1188315329734--