RE: [GENERAL] Tree structure

Поиск
Список
Период
Сортировка
От Jackson, DeJuan
Тема RE: [GENERAL] Tree structure
Дата
Msg-id F10BB1FAF801D111829B0060971D839F6B9468@cpsmail
обсуждение исходный текст
Список pgsql-general
I've gone over a scalable, flexable, robust, ... tree implementation
previously.  Search the archives (subject: 'A path through a tree',
date: 1-13-1999).
The layout is a bit different than the mainstream thinking, but with a
small logic change you get the ability to do an in-order tree/branch
select in one SQL select statement.  I have found no other method of
tree storage that didn't require you to use recursive selects.  Let me
know if you can't find my previous messages or if you need something
explained further.
    -DEJ

> -----Original Message-----
> From: K.T. [mailto:kanet@calmarconsulting.com]
> Sent: Friday, February 26, 1999 5:45 AM
> To: Kaare Rasmussen; pgsql-general@postgreSQL.org
> Subject: Re: [GENERAL] Tree structure
>
>
> Its been a while since I wrote this and its kinda fuzzy at
> this hour, but
> this will give you a general direction to go and you can work out the
> specifics...
> If you know the depth of the tree then you can create a field
> of a specified
> length and store something like:
>
> tree_field varchar(16)
> A
> AA
> AB
> ABA
> ABB
> ABC
> AC
>
> This allows you to select all records that are in level "B"
> fairly easily
> with a "like" clause.  Note that everything has a root of "A".
>
> Or you can create two fields:
>
> Parent/Child
> A/B
> B/E
> E/G
> B/F
> A/C
> A/D
>
> This one is confusing and there is no easy way to show the
> tree in text.
> You cannot use the same number for a node. eg.  if your first
> level is "A"
> then none of your sub levels can be "A".  So use the sequence
> generator to
> generate a unique key for each node.  Then your select would
> look something
> like this:
>    Select * from hierachy_table where parent_key = child_key
> and parent_key
> = "A";
> This should give you all branches under the "A" node.  To get the
> indention...hmmm try ordering the records by parent/child and
> writing code
> that loops thru the records?  That one stumps me...gotta
> sleep on it :)
>
> DISCLAIMER:  This might not be 100% accurate...its a seat of the pants
> memory.  Anyone who knows this please feel free to correct my
> errors :)
>
> -----Original Message-----
> From: Kaare Rasmussen <kar@webline.dk>
> To: pgsql-general@postgreSQL.org <pgsql-general@postgreSQL.org>
> Date: Friday, February 26, 1999 3:02 AM
> Subject: [GENERAL] Tree structure
>
>
> >I can't figure this one out. I need a tree structure like this
> >
> >Number  Pointer
> >1            0
> >2            1
> >3            1
> >4            2
> >5            0
> >6            1
> >7            5
> >
> >This should somehow show up like this
> >Number
> >1
> >2
> >4
> >3
> >6
> >5
> >7
> >
> >The whole excercise is because I'd like to show a tree structure:
> >
> >1
> >- 2
> >- - 4
> >- 3
> >- 6
> >5
> >- 7
> >
> >Is this possible with PostgreSQL?
> >
> >
>
>
>

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

Предыдущее
От: Clark Evans
Дата:
Сообщение: Re: [GENERAL] SQL/Relational Design Text Book recommendations
Следующее
От: "William Goldsmith"
Дата:
Сообщение: ERROR: ExecReScanSetParamPlan