pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: Devrim GUNDUZ <devrim@oper.metu.edu.tr>
Cc: PostgreSQL Mailing Lists-SQL <pgsql-sql@postgresql.org>
Subject: Re: A SQL Training
Date: Wed, 17 Jul 2002 10:00:55 +0300 (EEST)
Message-ID: <Pine.LNX.4.44.0207170948400.9911-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0207161957450.30332-100000@oper.metu.edu.tr>

On Tue, 16 Jul 2002, Devrim GUNDUZ wrote:

You need to identify your problem: preorder traversal on a tree
using pointers for the fathers.
Then you have to prove (or prove the opposite) that SQL alone
is capable of expressing what you need.

BTW, Nested Sets are only good for "static" databases.
Pointers are good for intensively "dynamic" databases, but have some
performance problems (for instance traversing to the root).
A genealogical approach (just like Oleg's and Teodor's one in 
contrib/tree) seems the most attractive.
Also you can have your own setup using postgresql arrays
(The arrays could contain the path of ids of the nodes from
the specific node to the root).
All these probably have little to do with your problem
(which is a computational theory problem), but maybe useful
in other cases.

> 
> Hi,
> 
> Today, one of my teacher asked me a question for a practice... I could not 
> solve it :)
> 
> Here it comes:
> 
> We are given the name of the grandfather in a family. Let's call him A. A 
> has n sons, each son has children .
> 
> for example.
> 		  A -> Grandfather
> 	         / \
> 	        /   \
>    	       B     C
> 	      /\   / \ \ 
>      	     /  \ D  E  F
>             G   H
>                 ...
> 
> We are given the data like ('A','B'),('C','D')...
> 
> Now, we do not know how many children are in the list. How could we list 
> this family tree in "tree" formt by only using SQL?
> 
> Best regards.
> 
> 
> 
> 
> 
> 

-- 
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-10-8981112
fax:    +30-10-8981877
email:  achill@matrix.gatewaynet.com
        mantzios@softlab.ece.ntua.gr




view thread (3+ messages)

Message-ID: <Pine.LNX.4.44.0207170948400.9911-100000@matrix.gatewaynet.com>
Permalink:  ../Pine.LNX.4.44.0207170948400.9911-100000@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0207170948400.9911-100000@matrix.gatewaynet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: achill@matrix.gatewaynet.com, devrim@oper.metu.edu.tr
  Subject: Re: A SQL Training
  In-Reply-To: <Pine.LNX.4.44.0207170948400.9911-100000@matrix.gatewaynet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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