Hi,
I'm new on this forum, hope you can help to solve my problem :)

I would like to modelize a binary tree like that

A
 / \
B   C
    /  \
   D   E

They will be more nodes be a node can only have a maximum of two children.

My question is about the MySQL Schema.
I was thinking about something like :
id | value | lchild | rchild
1 | A | 2 | 3
2 | B | ø | ø
3 | C | 4 | 5
4 | D | ø | ø
5 | E | ø | ø

What do you think about that ?

I saw many tutorials and articles about the Nedstet method but I think it's to heavy for what I want (travess, add, delete nodes).

Thanks for your help
Nico

Recommended Answers

All 2 Replies

Initially it looks as though you've answered your own question. The table and records shown build a binary tree which can be walked down or up.

So what isn't this doing that you want it to?

Juste need expert opinion to be sure :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.