Re: [SQL] Trees in SQL (again)

From: jwieck(at)debis(dot)com (Jan Wieck)
To: barteo(at)it(dot)pl (Bartek Teodorczyk)
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Trees in SQL (again)
Date: 1999-03-03 15:25:17
Message-ID: m10IDWQ-000EBQC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 1999-03-03 15:25:31 Re: question about pg_dump
Previous Message Bartek Teodorczyk 1999-03-03 15:00:08 Trees in SQL (again)