Re: Categories and Sub Categories (Nested)

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: Categories and Sub Categories (Nested)
Дата
Msg-id 71F2D761-D274-4453-8418-BEB2706503C0@myrealbox.com
обсуждение исходный текст
Ответ на Categories and Sub Categories (Nested)  ("Martin Kuria" <martinkuria@hotmail.com>)
Список 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




В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Glaesemann
Дата:
Сообщение: Re: How to implement a "subordinate database"?
Следующее
От: Don Y
Дата:
Сообщение: I18N