Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm importing some data from older database to new one. I'm considering the best SQL tree structure for categories. For now every level is saved in it's own table so they all have limited depth (numbered 3). I want to save them all into single table with relation info.

I have: all categories names with unique IDs with parent and child IDs. I want to introduce something like that: http://falsinsoft.blogspot.com/2013/01/tree-in-sql-database-nested-set-model.html. Unfortunately I don't know how to build lft and rgt IDs from my data.

For now my script gets all categories and save they IDs in database (single table) and in array, so if category has been added I have proper ID for the newer inserts. Then at the end I save relation in another table:

INSERT INTO tree_to_tree(id_child, id_parent) VALUES (".$idSeries.", ".$idBrand."), (".$idBrand.", ".$idProducer.")

How to convert this to BETWEEN - rgt and lrt values?

share|improve this question
1  
The "Adding New Nodes" section of the blog article to which you have linked (about halfway down) looks particularly relevant. Did you follow the examples? What went wrong? Where's your code? –  eggyal Jan 26 at 10:48
    
I didn't see this paragraph. I think I it's clear now. Thanks. –  PAM Jan 26 at 15:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.