Click here to Skip to main content
15,895,782 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi dear friends how can i manage category and product in database can nay one help me...

main category
1. dry clean

sub category
1. men
2. women

products maincatoery
1. piece soot 1
2. soot 1 second category
2. towel 2 second category
Posted
Comments
Legor 31-Aug-12 3:16am    
Not clear. What do you mean by "how can i manage". And where are you have problems exactly? Please improve the question.

Supposing that the level of hierarchy can vary, you can not simply use tree tables. Look here: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/[^]
 
Share this answer
 
Since you have a category with possible subcategories I'd go for modeling this as hierarchical data (More Trees & Hierarchies in SQL[^]).

You'd end up with a table like below for the categories:
(-1 indicates that a category does not have a parent and is thus a root category)
ID    Name      Description        ParentID
1     Dry Clean Dry cleaning stuff -1
2     Men       Clothes for men     1
3     Woman     Clothes for women   1


Then you need a means to relate which products are in which category so you'd create a relation:

ProductsPerCategory
CategoryID ProductID
1          1
2          2
3          3


Regards,

— Manfred
 
Share this answer
 
Comments
Khudha Bakhsh Mari 31-Aug-12 3:31am    
i have an image in which data is shown i want to share with u how can i upload it ...?
Manfred Rudolf Bihy 31-Aug-12 3:38am    
You could use http://imageshack.us/ for instance and the post the link to the image you uploaded in your question, so that all CPians can readily see that information.
Khudha Bakhsh Mari 31-Aug-12 3:54am    
hi dear friends this is the link of image please see ...

Please check this lilnk of image

Manfred Rudolf Bihy 31-Aug-12 4:11am    
What did I say about adding that to your question?
Use the "Improve question" link just below your question.
Manfred Rudolf Bihy 31-Aug-12 4:14am    
I just had a look at that image and don't really see what difficulties you have. Which part of my explanation did you not understand. You should really try to solve this yourself. You have enough hints now!

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