Last post Apr 28, 2010 04:43 PM by peterthegreat
Apr 24, 2010 10:47 AM|peterthegreat|LINK
I have a ordinary Category/Product database relationship Design structure.
Now i wish to add a sub category to this architecture.
for example, Cloths Category needs to be sub divided - Women,Men,Children categories.Also what about other Ctegories such as: Car,this also has sub divisions: Model,Type.
My Products table contains ProductName field together with generic field for Size,Colour and Price fields.
How do you therefore incorporate this sub division into the existing Category/Product relationship model and is there a model example?
Apr 24, 2010 02:43 PM|Mikesdotnetting|LINK
I would just add a Subcategory table, containing a Primary Key, description and the Category ID as a foreign key. then your Prducts table will need to reference the SubcategoryID. It won't need a link to the CategoryID any more, as that will be accessible
via the relationship between the subcategory table and the category table.
Apr 24, 2010 04:11 PM|ammd|LINK
Apr 26, 2010 08:22 AM|peterthegreat|LINK
It is an interesting design .thou i dont understand how the ParentID column is implemented.
does it relate to another table? and is it a key type column?
Apr 26, 2010 06:40 PM|ammd|LINK
The ParentID column is infact the CategoryID column, its a self-relationship to the single table. Hope this makes sense.
Apr 27, 2010 01:31 PM|peterthegreat|LINK
This does seem like the best option considering i dont want to go to deep in categories and what i read about the other method the sql code can prove difficult and i want a seemless integration with my current application.
i was wondering if this was your reasons given the criteria.
Apr 27, 2010 02:45 PM|ammd|LINK
Personally I have used this method as it allows me to have solutions that can go deeper as and when the requirement arises. Plus the same principle can be applied to things like Navigation and other types of criteria.
Hope this helps.
Apr 28, 2010 04:43 PM|peterthegreat|LINK
i have discovered that it does not disrupt original code configurations because the id field remains the same.
but how do you define sql statements .For example, retrieve the level 3 sub category.
I will want to list sub values using multi dropdownlists or other?