I have a category table like this:
I can list categories as list and subcategories as dropdown list but My designer send me a design that categories have subcategories with the same name:
How can I manage this type of subcategories?
Thanks in advance
Sounds to me a "design" issue rather than a database issue.
You can add a dash symbol before the subcategories names in the dropdown, so the options values would be:
Category 1
-Subcategory 1
-Subcategory 2
Category 2
-Subcategory 1
-Subcategory 2
My appending " -" before the subcategory's title, you are creating levels in the dropdown, which the user can visually see, and recognize where each subcategory belong to.
It's not a perfect solution, but it's sure easy to implement. If you're willing to spend time on it, try research jquery plugins that have multi level select boxes support, such as http://php4bd.wordpress.com/2007/07/15/javascript-controlled-dependent-or-cascading-select-list/
You have id to uniquely identify your tuples. Duplicated names aren't a problem.
Also read: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/