Hello all,
I have a question and I wonder if this is possible. I want to create a tree structure like this:
NODE-1
Child-1
NODE2
Child-21
Child-211
Child-212
Child-22
Child-221
Child-222
NODE3
Child-31
Child-311
Child-3111
Child-3112
Child-3113
Child-312
Child-3121
Child-3122
Child-3123
Child-313
Child-3131
Child-3132
Child-3133
Child-32
Child-321
Child-3211
Child-3212
Child-3213
Child-322
Child-3221
Child-3222
Child-3223
Child-323
Child-3231
Child-3232
Child-3233
Child-33
Child-331
Child-3311
Child-3312
Child-3313
Child-332
Child-3321
Child-3322
Child-3323
Child-333
Child-3331
Child-3332
Child-3333
NODE4
Child-41
...
Child-411
...
Child-4111
...
Child-41111
...
Given a number, I would like to generate a recursive structure as illustrated above.
If I have number is 1, then I generate ONE Node having one child.
If I have number 1, then I generate TWO NODES. Nodes 1 & 2. Then for each nodes, I generate two children and for each of these ttwo children, I generate two other children.
For number 3, I do exactly the same logic. 3 nodes, having 3 direct child, etc… This can produce quickly a lot of descending nodes. So I guess I shouldn't try with big numbers. But, I was wondering how we can handle these backtracking topics using SQL statements.
Any idea?