I have a different situation that a category can be a sub category of more than one category. How should I design this ?
The tree structure below doesnt solve my problem I guess. Should I do ParentCategoryId as a string and can take multiple category id in it. Then do calculation to resolve parent categories or do you advise me another solution ? What is your optimum solution to solve this problem ?
--Category--
Id
ParentCategoryId
CategoryName
Thanks in advance,
The standard SQL solution for this is a cross table. You would have two tables, categories and categories_x as follows:
To get the parents of category 3 your sql query would look like: