pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rudi Starcevic <rudi@oasis.net.au>
To: pgsql-sql@postgresql.org
Subject: Re: Linked Lists example.
Date: Mon, 15 Sep 2003 10:05:15 +1000
Message-ID: <3F65023B.5030707@oasis.net.au> (raw)
In-Reply-To: <20030914112437.M72412@oasis.net.au>
References: <20030914112437.M72412@oasis.net.au>

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
>>
>>  
>>
>






view thread (3+ messages)  latest in thread

Message-ID: <3F65023B.5030707@oasis.net.au>
Permalink:  ../3F65023B.5030707@oasis.net.au/
Also on:    postgresql.org/message-id/3F65023B.5030707@oasis.net.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rudi@oasis.net.au
  Subject: Re: Linked Lists example.
  In-Reply-To: <3F65023B.5030707@oasis.net.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox