A database table design help
Posted on 2005-04-23
I am creating an ecommerce website where user can purchase our product.Product will be published under a category or subcategory.Howeveri got problem with table design.
Under this site there will be category,subcategory and product.For category there will be only one hiearchy of category.But for subcategory there will be infinite subcategory.Here is the example.
For example if there is a category named A, then under this category there will be a subcategory called B. Under this subcategory B, there will be another subcategory c and this hierachy will be infinte.
While adding a product administartor can add his product on any existing category or subcategory. For example A product named "AA" can be added under category
"A" or subacategory "B" or subcategory "C".While displaying data if that product is added under category "A" it should display like "A>AA",or if it is created under subcategory B it should display like "A>B>AA". Likwise if it is created under the subcategory "C"
it should look like "A>B>C>AA".
Category can be added in one table so this is fixed and got no problem.But I have problem with desinging the subcategory table.How can i design that table so that it contains infinite hiearcy of subcategory.
Like wise while displaying a prdouct how can we display it under my requirements.
I don't need any coding for this. I just need a lograthim.
ThanKs in Advance