Link to home
Start Free TrialLog in
Avatar of danishbacker
danishbacker

asked on

best method to implement a family tree ?

I need to make a family tree. But i don't know how to make make it.
I asked someone and done some searching in Google.
I found three ways as follows
1. Using Database (foreign key to represent relation ship)
2. Using XML to store the data.
3. Using binary tree.

But the problem is I am not familiar with any of the above.
Please suggest me the easiest way to this. Also I need to make the list dynamic.
Also any new method which is simpler than the above.

If you can suggest some sample code please make it in php.

Thanks in advance,
SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hehe ... I remember a course at the university that was quite similar. Most people's family trees are hierachical ... unfortunately not all families. In my case we had to display the family tree of Egypt's pharaos and this tree contains a few cycles ... the Database approach is the approach which is best resistant against structural problems ... afer all ... you only have one father and one mother. Doing this in Xml could get tricky ... not impossible, but tricky.
Define "tricky"? But I assume you mean that forcing the relationships is just harder. Which is where XSD or RelaxNG comes in,which can be considered what is known as a Database Design for database, but then for XML. Then the "tricky" bit goes away...

Obviously, anything will be tricky unless you know how to define the relationships.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of danishbacker
danishbacker

ASKER

Thank u both for trying to help me,

I think it is better to go with XML even if dont know it well.
I found many different approaches in XML too
like Parsing XML using DOM, SAX ...?
which one should i use ?
i may need to add and edit child node or some time new family.

is it difficult to do that using XML?

At first I tried to do this with database but it seems very difficult to me, as cud not design the database well.

Also i need to make a view of this family tree.
Special Thanks to Abel
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In general Sax is great for transforming, Dom is the method of choice, if you want to work with the thing. Cou can think of Sax being someone reading the document out loud and you can hook on to events and read out your own stuff. But after a tag is "read" and all listeners have finished, the information is gone. In dom you get an object representation of the entire document. I'd suggest sticking to the DOM approach.
I am happy with the solution. Both of you recommended the same thing (DOM).
I'll carry on with the DOM approach. I think I now know where to start.
 :)

I'll come again if I have doubts when doing this. Hope you people will help me.

Many Thanks to Abel and ChristoferDutz.