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