X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B3211D1B4E2 for ; Mon, 15 Sep 2003 00:00:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 22962-10 for ; Sun, 14 Sep 2003 21:00:39 -0300 (ADT) Received: from water.oasis.net.au (water.oasis.net.au [210.8.139.2]) by svr1.postgresql.org (Postfix) with ESMTP id CBFA7D1B4F5 for ; Sun, 14 Sep 2003 21:00:33 -0300 (ADT) Received: from oasis.net.au (guardian [210.8.139.5]) by water.oasis.net.au (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id KAA06398 for ; Mon, 15 Sep 2003 10:30:56 +1000 X-Authentication-Warning: water.oasis.net.au: Host guardian [210.8.139.5] claimed to be oasis.net.au Message-ID: <3F65023B.5030707@oasis.net.au> Date: Mon, 15 Sep 2003 10:05:15 +1000 From: Rudi Starcevic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Linked Lists example. References: <20030914112437.M72412@oasis.net.au> In-Reply-To: <20030914112437.M72412@oasis.net.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/127 X-Sequence-Number: 15105 Jesse, Thanks - that's a good example. Could you also have built you CMS solution without linked lists ? I'm curious to see if the rule 'there's more than one way to the top of the mountain' applies here as it usualy does. Cheers Rudi. Jesse Scott wrote: > In my current CMS project, I use a linked list concept. I've never > read about linked-lists specifically for SQL, so I don't know if there > are any nuances I missed by applying a basic CS approach to it. > Anyway, here are simplified versions of a few of my tables: > > content > ---------- > cid serial > title varchar(255) > first_element int4 (FK -> content_elements.element_id) > > content_elements > ------------------ > element_id serial > type varchar(64) (FK -> element_types.element_type_id) > next_element int4 (FK -> content_element.element_id) > > Now, in content_elements I also have a few fields that are foreign > keys to the various tables that actually hold the different element > types such as paragraphs, images, etc... I should really write some > custom triggers to really ensure things end up linked correctly. But > so far it has been working well. Whenever content is "published" I > walk the linked list and build static HTML out of the article so that > displaying content isn't very database intensive. > > There have been a couple times when I've wished I had made it a > doubly-linked list, so I'll probably add that in the next version, but > that's just a convenience thing basically. Makes it easier to move > elements around and delete them etc... > > Let me know if I didn't explain this very well, I'd be happy to send > you the actual database specs and some sample code. > > -Jesse > > > Rudi Starcevic wrote: > >> Hi, >> >> Can anyone give me a real world example of where a 'linked list' >> would be used in PostgreSQL or SQL in general. >> Just been reading up a little on them and am wondering how/when to >> use them. >> >> Many thanks >> Rudi. >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 9: the planner will ignore your desire to choose an index scan if >> your >> joining column's datatypes do not match >> >> >> >