I came to situation, where I had to ask to increase my knowlege. I this is very basic question, but I am learning.
Database is about articles, suppliers etc. It has three levels of categories.
CategoryMain, SubCatLevel1, Subcatlevel2.
Not all the subcategories of level1 are further subcategorized to level2. So basically the last sub category (over all 3rd level) is shrinked.
And I know the last level (subcategorylevel2_ID) will serve as foriegn key in article detail table.
What about those articles who have level1 but dont have level2 of subcategory?
What is the best solution in this case?
Example below
1) CategoryMain
2nd category also decides about tax percentage (19%, 7%, 0%)
2) SubcategoryLevel1
3) SubcategoryLevel2
For better understanding, what I mean is - If I combine the text of all, it look like as below
CategoryQ
thank you
Database is about articles, suppliers etc. It has three levels of categories.
CategoryMain, SubCatLevel1, Subcatlevel2.
Not all the subcategories of level1 are further subcategorized to level2. So basically the last sub category (over all 3rd level) is shrinked.
And I know the last level (subcategorylevel2_ID) will serve as foriegn key in article detail table.
What about those articles who have level1 but dont have level2 of subcategory?
What is the best solution in this case?
Example below
1) CategoryMain
| ID_CategoryMain | CategoryMain |
| 1 | General |
| 2 | Groceries |
2nd category also decides about tax percentage (19%, 7%, 0%)
2) SubcategoryLevel1
| ID_Subcatlevel1 | ID_CategoryMain | Subcatlevel1 | ID_TaxRate |
| 1 | 2 | Fruits-Vegetables | 2 |
| 2 | 2 | Rice | 2 |
| 3 | 2 | Flour | 2 |
| 4 | 2 | Spices | 2 |
| 5 | 2 | Drinks | 1 |
| 6 | 1 | All | 1 |
| 7 | 1 | Men | 1 |
| 8 | 1 | Women | 1 |
| 9 | 1 | Kids | 1 |
3) SubcategoryLevel2
| ID_CatSubLevel2 | ID_Subcatlevel1 | Subcatlevel2 |
| 1 | 8 | Clothes |
| 2 | 8 | Jewelry |
| 3 | 8 | Shoes |
| 4 | 9 | Bikes |
| 5 | 9 | Clothes |
| 6 | 9 | Toys |
For better understanding, what I mean is - If I combine the text of all, it look like as below
CategoryQ
| CategoryMain | Cat level 1 | Cat level 2 |
|---|---|---|
| General | All | |
| General | Men | |
| General | Women | Clothes |
| General | Women | Jewelry |
| General | Women | Shoes |
| General | Kids | Bikes |
| General | Kids | Clothes |
| General | Kids | Toys |
| Groceries | Fruits-Vegetables | |
| Groceries | Rice | |
| Groceries | Flour | |
| Groceries | Spices | |
| Groceries | Drinks |
thank you