dbTalk Databases Forums  

Nodes, trees, relationships...

comp.databases comp.databases


Discuss Nodes, trees, relationships... in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bonjella
 
Posts: n/a

Default Nodes, trees, relationships... - 10-09-2007 , 04:09 AM






Hi all,

I want to do something, but I'm not sure where to start - I think
part of the problem is I'm not sure of the correct language for what I
want to achive so my searching isn't returning anything very useful.

My final aim is to display a diagram showing the relationships
between nodes, so, first, I need to store these nodes and their
relationships in a database, then to query them so I can create my
diagram.

My nodes have relationships with other nodes, the relationships are
two way (so if A likes B, then B likes A, or if the road goes from A
to B, then it also goes from B to A), I started with a tree, but some
nodes have more than one parent, and sometimes have a parent that is
it's other parent's great uncle - I've not used a tree like this
before.

So, where do you think I should start? These are some of the
relationships I have thus far

1-2
1-3
1-4
3-4 <-- siblings, both children of 1
4-5
3-5
5-6
2-6 <-- this is the one that 'brakes' my original simple tree idea

Does this type of 'tree' have a name?

I'm intending to use MySQL (or SQL server) to store the info, then
PHP to pull it out and do things with it

Any advice greatfully recived :-)

Amy


Reply With Quote
  #2  
Old   
--CELKO--
 
Posts: n/a

Default Re: Nodes, trees, relationships... - 10-10-2007 , 11:54 AM






Quote:
I think part of the problem is I'm not sure of the correct language for what I want to achieve so my searching isn't returning anything very useful.
What you described is a general undirected graph. A tree is special
case of a graph and it is usually directed. Dover Books has several
good cheap intro books on the topic, but the easiest reads are:

Introductory Graph Theory by Gary Chartrand (ISBN: 0486247759)
Introduction to Graph Theory by Richard J. Trudeau (ISBN: 0486678709)

The only way I have found to do this in SQL is with a table of Nodes
and a table of Edges. After that, you mimic procedural code from a
book on graph algorithms. I like the pseudo-code in

Algorithmic Graph Theory by James A. McHugh (ISBN 0-13-023615-2)

Quote:
My final aim is to display a diagram showing the relationships
between nodes, so, first, I need to store these nodes and their
relationships in a database, then to query them so I can create my
diagram. <<

We don't do diagrams in SQL; that is the job of the front end. The
Edges table has the relationships in it and you can probably pass them
to an drawing tool of some kind.

Quote:
My nodes have relationships with other nodes, the relationships are two way (so if A likes B, then B likes A, or if the road goes from A to B, then it also goes from B to A), I started with a tree, but some nodes have more than one parent [sic], and sometimes have a parent [sic] that is it's other parent's [sic] great uncle - I've not used a tree like this before.
That is not a tree by definition. As quick check, the number edges in
a tree is (# of nodes)-1. Then you need to check for cycles; a tree
has no cycles.

Quote:
These are some of the relationships I have thus far:
1-2
1-3
1-4
3-4 <-- CYCLE!!
4-5
3-5 <-- CYCLE!!
5-6
2-6 <-- CYCLE!!
<<



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.