Page 1 of 1

data design :: products belonging to more than 1 category

Posted: Wed Nov 03, 2004 8:28 am
by kendall
hello,

i have an instance where i have a product that falls into more than one category. Now this is strange to me so i am just looking for advice on the approach to designing this. As there is a main category and the other category is more for a searching tool that allows the visitor to view products based on different criteria.

Kendall

Posted: Wed Nov 03, 2004 8:42 am
by timvw
if you are talking about databases:

there is a relation [product] n ------ m [category]


this can't be modelled, and therefore they use a helpentity, which results in :
[product] 1 ---- n [productcategory] n ------- 1 [category]

Posted: Wed Nov 03, 2004 8:50 am
by kendall
Timvw, yes i was talking about databases. However i can't create a relationship between the main and other category cause...there isnt any
relation to it the relation of the category exist between themselves and the product
product1 --- main category1
product1 -- category2 ---
product2 -- main category1
product2 -- category3
BUT
main category1 != category2

Posted: Wed Nov 03, 2004 9:27 am
by CoderGoblin
Hello Kendall,

I would have a "search table", as well as standard product/cat tables (e.g search_prod2cats)
only 2 columns are required prod_ref and cat_ref. A product can be in the table multiple times, as can a category. This can then be used as a join in the search SELECT.

Another option is to have "product keywords" as a string in a new product table column and search using like '% word %'.

Given the choice however I would go with the first one.