Recursive SELECT?

“rather than new category, then assigning each product to the new category…”

No… you dont create a new category for each product… you add new products to existing categories. That way you dont have to change any of the existing products when you add a new one, or sell a current one.

EX:

Your chain is productIDs:

1-2-4-5-8

You sell product 4. Now you’ve got to do 3 things:
Remove product 4.
Update product 2 to point at product 5
Update product 5 to point at product 2
…to maintain your chain.

If all 5 of the products belong to category 1, you just… delete product 4. The rest of the products dont care. They still belong to category 1.

If you need to add a product to your chain, you have to:
find a chain member that doesnt already have a child.
add the new product
update the chain member from before to point at the new product

Or…
add the product with categoryID = 1

Done.

Agreed.