From: | Michael Glaesemann <grzm(at)myrealbox(dot)com> |
---|---|
To: | Martin Kuria <martinkuria(at)hotmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Categories and Sub Categories (Nested) |
Date: | 2006-04-20 00:39:00 |
Message-ID: | 71F2D761-D274-4453-8418-BEB2706503C0@myrealbox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Apr 19, 2006, at 14:44 , Martin Kuria wrote:
> I have a postgresql database Table Categories which has the
> structure like this
>
> Cat_ID | Parent_ID | Name
> ------------------------------------
> 1 | 0 | Automobiles
> 2 | 0 | Beauty & Health
> 3 | 1 | Bikes
> 4 | 1 | Cars
> 5 | 3 | Suzuki
> 6 | 3 | Yamaha
> 7 | 0 | Clothes
>
> According to the above Database data, Suzuki and Yamaha are the
> Subcategories of Category Bikes and Bikes in turn is the
> Subcategory of Automobiles.
If you're looking at having a potentially deep hierarchy, I'd
recommend taking a look at nested sets, which also allows you to keep
everything in one table.
http://www.intelligententerprise.com/001020/celko.jhtml?
_requestid=145525]
By the way, the method you outline above is often called the
adjacency list model.
Hope this helps.
Michael Glaesemann
grzm myrealbox com
From | Date | Subject | |
---|---|---|---|
Next Message | Orion Henry | 2006-04-20 02:39:45 | primary keys |
Previous Message | Michael Glaesemann | 2006-04-20 00:14:44 | Re: How to implement a "subordinate database"? |