Received: from orion.SAPserv.Hamburg.dsh.de (Tpolaris2.sapham.debis.de [53.2.131.8]) by hub.org (8.9.2/8.9.1) with SMTP id KAA20052 for ; Wed, 3 Mar 1999 10:20:37 -0500 (EST) (envelope-from wieck@sapserv.debis.de) Received: by orion.SAPserv.Hamburg.dsh.de for pgsql-sql@postgreSQL.org id m10IDWQ-000EBQC; Wed, 3 Mar 99 16:25 MET Message-Id: From: jwieck@debis.com (Jan Wieck) Subject: Re: [SQL] Trees in SQL (again) To: barteo@it.pl (Bartek Teodorczyk) Date: Wed, 3 Mar 1999 16:25:17 +0100 (MET) Cc: pgsql-sql@postgreSQL.org Reply-To: jwieck@debis.com (Jan Wieck) In-Reply-To: <36DD4E78.9BC36320@it.pl> from "Bartek Teodorczyk" at Mar 3, 99 04:00:08 pm X-Mailer: ELM [version 2.4 PL25] Content-Type: text > > 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) #