Re: Database planning - Hierarchical problem - Help needed

From: Lennart Jonsson <lennart_at_kommunicera.umea.se>
Date: 29 Nov 2004 12:22:21 -0800
Message-ID: <6dae7e65.0411291222.508a0740_at_posting.google.com>


philippe.lecomte_at_step.fr (Philippe) wrote in message news:<ee069cd0.0411290350.474746ae_at_posting.google.com>...
> Hi,
>
> I'm actually on a problem i don't manage to resolve.
> I want to implement a thing like this in a table :
>
> Albert John
> / \ /
> / \ /
> Bert Chuck
> / | \
> / | \
> / | \
> / | \
> Donna Eddie Fred
> \ /
> \ /
> \ /
> Gilbert
>
>
>
> All these links are work relationship between employees...
> So for example, Bert superior is Albert.
> And Chuck has two superiors : Albert and John
>
> What's in ur point the best method to organize this in a table and do
> simple queries on it ?
>
> I tried a modified preorder tree traversal algorithm but since it's
> not hierarchical anymore, i don't manage to get it to work... (some
> item have two superiors)
>

Representing such graphs in sql is a tough task. Here is one article describing some of the problems youre facing:

Maintaining the transitive closure of graphs in SQL. Guozhu Dong, Leonid Libkin, Jianwen Su and Limsoon Wong. Int. Journal of Information Technology, 5 (1999), 46-78.

You can find an electronic version on the page

http://cm.bell-labs.com/who/libkin/publ.html

If you db supports recursion you can try that, but watch out for cycles

HTH
/Lennart

[...] Received on Mon Nov 29 2004 - 21:22:21 CET

Original text of this message