Best way to store nodes in the database so that its will be easy to create Tree.
Dear Friends,
Fields Created in the table are
Key | Name | Parent
--------------------------------------
101 | Computer |
102 | Software | 101
103 | Harware | 101
104 | Java | 102
105 | Ram | 103
Tree will look like
Computer
|
|_____Software
| |
| |______java
|
|_____Hardware
|
|______Ram
I m feeding the table in this format , Its very tedious to develop tree from the structure like this.
Second way i m thinking is
Key | Name | Parent
--------------------------------------
101 | Computer |
102 | Software | 101
103 | Harware | 101
104 | Java | 101\102
105 | Ram | 101\103
Please suggest me some way so that it would be easy to create tree.
and if possible please provide some demo code.
Re: Best way to store nodes in the database so that its will be easy to create Tree.
Storing trees in SQL is not easy. See the following for two methods of storing tree data. Each has its advantages and the above example represents the first method.
Managing Hierarchical Data in MySQL
Re: Best way to store nodes in the database so that its will be easy to create Tree.
Thank you very much
Its really worthy.
Thanks for the quicker resonse.