N level recursion and numbers

I want to get this
others(other_id,other_name,parent_id…)
cats(cat_id,name,parent_cat_id,parent_other_id,…)

1.(other cat 1-from others table)
1.1 (child of other Cat1-from others table)
1.1.1 (child of other Cat1.1 -from cats table)----it uses recursive function to get child upto nth level
1.1.2
1.1.3
1.1.3.1 (child of other Cat1.1.3 -from cats table)
1.1.3.2
1.1.3.2.1
1.1.3.2.2

2.1
2.1.1
2.1.2
2.1.3
2.1.3.1
2.1.3.2
2.1.3.2.1
2.1.3.2.2

I have used one logic…but i am not fully satisfied with it…so any help would be great.

Why do you have two tables? What do they contain?

I have used one logic…

Could you explain that logic?