X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id AD73A9FB2C3 for ; Tue, 15 Aug 2006 13:01:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 40678-08 for ; Tue, 15 Aug 2006 16:01:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id 8D2C99FB2C2 for ; Tue, 15 Aug 2006 13:01:45 -0300 (ADT) Received: by noel.decibel.org (Postfix, from userid 1001) id E977856437; Tue, 15 Aug 2006 11:01:25 -0500 (CDT) Received: (hashcash-sendmail, from uid 1001); Tue, 15 Aug 2006 11:01:24 -0500 Date: Tue, 15 Aug 2006 11:01:24 -0500 From: "Jim C. Nasby" To: Sue Fitt Cc: Chris , pgsql-performance@postgresql.org Subject: Re: setting up foreign keys Message-ID: <20060815160124.GQ27928@pervasive.com> References: <44DAE8CF.1030107@inf.ed.ac.uk> <44DAEB04.9050306@gmail.com> <44DAF6B7.1090800@inf.ed.ac.uk> <44DAF8B9.2080000@gmail.com> <44DAFA6D.4070606@inf.ed.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44DAFA6D.4070606@inf.ed.ac.uk> X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Hashcash: 1:20:060815:sue@inf.ed.ac.uk::5MJ1Ps267INMZO/T:04OZ5 X-Hashcash: 1:20:060815:dmagick@gmail.com::FphwRLl5Ch5F9cpU:00000000000000000000 0000000000000000000000002egA X-Hashcash: 1:20:060815:pgsql-performance@postgresql.org::4qHqwGGSfpyrEqpZ:00000 0000000000000000000000003X5x X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200608/226 X-Sequence-Number: 20411 On Thu, Aug 10, 2006 at 10:20:45AM +0100, Sue Fitt wrote: > Well they don't necessarily have the same value! > > It's a dictionary with cross-referenced words, e.g. 'bring' and > 'brought' are both headwords in the dictionary, but 'brought' is > cross-referenced to 'bring'. So, the table stores the information (using > integer id's rather than words) that > bring: bring > brought: see bring > sing: sing > sang: see sing > etc. If that's actually how it's represented (a row for both sing and song) it's denormalized. My rule of thumb is "normalize 'til it hurts, denormalize 'til it works", meaning only denormalize if you need to for performance reasons. In this case, it's certainly possible that performance-wise you're best off denormalized, but you might want to experiment and find out. BTW, the normalized way to store this info would be to only put records in that table for brought and song. > Sue > > Chris wrote: > >Sue Fitt wrote: > >>Thanks Chris and Chris, you've solved it. > >> > >>I had a gui open that connects to the database. It was doing nothing > >>(and not preventing me adding to or altering headwords_core via > >>psql), but having closed it the table is instantly created. Weird. > >> > >>BTW, referencing the same column twice is deliberate, it's a > >>cross-reference. > > > >The same column and the same table? > > > >Same column different table I could understand but not the same column > >& table ;) > > > >I'm sure there's a reason for it though :) > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend > -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461