pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Trees in SQL (again)
2+ messages / 2 participants
[nested] [flat]

* Trees in SQL (again)
@ 1999-03-03 15:00  Bartek Teodorczyk <barteo@it.pl>
  0 siblings, 1 reply; 2+ messages in thread

From: Bartek Teodorczyk @ 1999-03-03 15:00 UTC (permalink / raw)
  To: pgsql-sql

I'm trying to implement set model of trees in SQL and I found a problem:

How to find first level children of parent?

For this structure (with left and right set values):

          1 Jerry 10
              |
     -------------------
     |                 |
 2 Bert 3          4 Chuck 9
                       |
                 ------------
                 |          |
             5 Donna 6  7 Fred 8

The question is: Who is first level child of Jerry?
The answer should produce:
        Bert
        Chuck

BarTeo



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [SQL] Trees in SQL (again)
@ 1999-03-03 15:25  Jan Wieck <jwieck@debis.com>
  parent: Bartek Teodorczyk <barteo@it.pl>
  0 siblings, 0 replies; 2+ messages in thread

From: jwieck@debis.com @ 1999-03-03 15:25 UTC (permalink / raw)
  To: barteo@it.pl; +Cc: pgsql-sql

>
> I'm trying to implement set model of trees in SQL and I found a problem:
>
> How to find first level children of parent?
>
> For this structure (with left and right set values):
>
>           1 Jerry 10
>               |
>      -------------------
>      |                 |
>  2 Bert 3          4 Chuck 9
>                        |
>                  ------------
>                  |          |
>              5 Donna 6  7 Fred 8
>
> The question is: Who is first level child of Jerry?
> The answer should produce:
>         Bert
>         Chuck

    The  children  must  know. It is the same situation as in the
    unix filesystem. And that's why there  is  a  '..'  entry  in
    every directory, pointing to the inode of the parent.

    So  each  node must have a field identifying it's parent. The
    root node (Jerry)  might  simply  point  back  to  itself  to
    identify that.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== jwieck@debis.com (Jan Wieck) #





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1999-03-03 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-03-03 15:00 Trees in SQL (again) Bartek Teodorczyk <barteo@it.pl>
1999-03-03 15:25 ` Jan Wieck <jwieck@debis.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox