Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> transitive closure code and SQL wanted

transitive closure code and SQL wanted

From: Steven Tolkin <steve.tolkin_at_fmr.com>
Date: 13 May 2002 06:41:48 -0700
Message-ID: <107e75b8.0205130541.decb964@posting.google.com>


Summary:
I want to get code (includes the the database DLDL and queries) that will compute the transitive closure of a graph (actually a tree). I am willing to pay a reasonable amount, but reliable freeware or shareware is fine.
The database can be MS Access, MS SqlServer, or Oracle. The code can be in ASP, VB, Perl, or JavaScript. This should be as close to a "turnkey" tool as possible, but I also would prefer having the source code. But I could settle for binary only if well documented and supported.
Other keywords sometimes used to describe this problem: self-join, recursive hierarchy.

 Details:
My data is a tree of nodes.
Suppose I have a table named node_parent that has two columns: node_id and parent_id.
I want the code that will calculate a table named node_ancestor having the two columns: node_id and ancestor_id.

(The names I use for tables and columns are just examples; they can have other names and other structure.)

I also would like a GUI that presented the parent_child data, e.g. in a tree control or other editable GUI. To support this the node_parent table needs another column, named e.g. local_order, that holds the order among the siblings.

It would be nice if the code also populated a column in node_ancestor that showed either the depth of the ancestor and/or the distance from the node to its ancestor. The point is to support the query that given a node, shows all its ancestors in the order parent, grandparent, ... root.

Ideally the node_ancestor table will also contain a global_order column that is populated as the table is constructed.

I am aware of the technique that assigns each node in the node_parent table a pair of numbers for the left and right edes of the interval defined by its descendants. Using this technique is fine, provided the code to referesh these after editing the the tree is included. I do not care how the root node is denoted; using either a NULL value or its own node_id is OK.

Since my node_parent_child table should be a single tree it would be nice if the code complained if it found otherwise, e.g. multiple root nodes, unreachable nodes, multiple parents, or a cycle.

Thanks,
Steve

-- 
Steven Tolkin          steve.tolkin_at_fmr.com      617-563-0516 
Fidelity Investments   82 Devonshire St. V8D     Boston MA 02109
There is nothing so practical as a good theory.  Comments are by me, 
not Fidelity Investments, its subsidiaries or affiliates.
Received on Mon May 13 2002 - 08:41:48 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US