Re: Table-design for categories, suggestions needed - Mailing list pgsql-novice

From Richard Broersma
Subject Re: Table-design for categories, suggestions needed
Date
Msg-id A835E918-24D8-4AE1-BA43-9B04C1EF3DAA@gmail.com
Whole thread Raw
In response to Re: Table-design for categories, suggestions needed  (Rikard Bosnjakovic <rikard.bosnjakovic@gmail.com>)
List pgsql-novice
On Aug 5, 2010, at 3:50 PM, Rikard Bosnjakovic
>
> Perhaps a better example is an Ebay-listing. For a random page I have
> open right now I see at the top: "Listed in category: Mobile & Home
> Phones > Mobile Phone Accessories > Other Mobile Phone Accessories >
> Other Mobile Phone Accessories".
>
> This "chain" is what I'm trying to duplicate.


Okay, then what you are trying to model is a tree.

Postgresql has a special contrib module called Ltree that manages this nicely.

Other than this, there are three data models that you can choose from:

Adjacency list model Aka BOM model
Path enumeration model
Nested set model

The first model is probably the easiest to grasp.  And since pg 8.4 supports recursive queries this model becomes a
nicechoice.  

Sent from my iPod

pgsql-novice by date:

Previous
From: Leon Starr
Date:
Subject: Best way to test/develop lots of nested functions?
Next
From: "Carel Combrink"
Date:
Subject: Libpq in C Language Function