The categories under User B are totally separate from the categories under User A. What User B puts under his Science category does not affect the Science category of User A.
Consider these scenarios:
1) User A wishes to create another "Science" category that has no parents.
Desired outcome: He should not be allowed to, because he already has such a category.
2) User A wishes to create his own Videos category without parents.
Desired outcome: He should be allowed, since he has no such category of his own.
3) User A wishes to create another Videos category under his Biology category, giving him two separate and independant Videos categories.
Desired outcome: He should be allowed to, because there is no Videos category under Biology yet.
4) User A tries to repeat scenario 3.
Desired outcome: He should not be allowed to, since there already exists an Video category under his Biology category.
Take scenario 3. If I merely check to see whether or not some category named Biology has a subcategory called Videos, then I risk a false positive because there does exists a category named Biology with a subcategory called Videos, BUT they belong to user B. I only want to check if this is true or not for User A.
So, I need some code that can handle the above scenarios.
The parent category name is provided by the user as of now, but I think your idea of having a select box is better.
There is no subcategory model. Each category row has a parent field. That's how I did it.
I hope I was clearer this time. Thanks for helping :-)