Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Just take an example of this....
[ Footwear->men's->shoes ]->all product
[ Footwear->women's->shoes ]->all product
[ Clothes-->men's--->T-shirt ]->all product
[] implies category of product

So this is hierarchy of a site.

Product table
---------------------
pID Name CategoryId
1 Shoe1 here my question lies

1)What should be category table design?

catId ParentId Name
1 0 Footwear
2 1 men's
3 2 shoes
4 1 women's
5 4 shoes
6 0 clothes
I think this should be.Right?
C#


2)If this is right,what should be product table design?
In product table which will be my categoryid?
As there is no child of shoes,so for men's shoe product "3" should be category id.Am I right?

So in menu if I click shoes from men's tab I can get 3 and by query I can fetch all men's shoes.
But if I click footwear,then all type of foot wears(shoes,ketos) of men and women are loaded.So how to do this?

If I create product table like

pid pname gender type1 type2
1 shoe1 men's shoe footwear
2 keto1 women's keto footwear

then query will be very simple.Clicking on footwear I can get all product of footwear.
clicking on men's I can get all product of men's.

But in this case unlimited hierarchy is not possible (because types are fixed in columns).


=>So my question is what is the best approach to do this type of job?
=>In this type of case how to create breadcrumb
on clicking footwear it should be Home>footwear
on clicking men's-shoes it should be Home>footwear->men's>shoes

Please help.
Posted
Comments
ZurdoDev 12-Feb-15 22:13pm    
There's always more than one way to do something. Go with what you know.
souvikcode 12-Feb-15 23:10pm    
Just read my question please. I've shown two ways which have pros and cons.But in shopping cart they implement this.That's why I want to know how do they implement?I know there is many ways.But if you know a way which can overcome my problem,please tell.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900