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?