best way to optimize a table with many to few relationship.

2003-02-04 Thread Ken Easson
hello, I have a question about database structure and optimization. I have a shopping cart where several items can fall into several of many categories, but each item can also be several of a few product types. my product type is limited to aprox. 5 product types. Further 99% of items will be

best way to optimize a table with many to few relationship.

2003-02-04 Thread Ken Easson
hello, I have a question about database structure and optimization. I have a shopping cart where several items can fall into several of many categories, but each item can also be several of a few product types. my product type is limited to aprox. 5 product types. Further 99% of items will be

RE: best way to optimize a table with many to few relationship.

2003-02-04 Thread Grigor, Peter
What you're talking about is a many-many relationship, as one product can belong to many categories, and one category can encompass many products. The best way to implement this is to have a [category] table, a [product] table, and a [categoryproduct] table. The latter table implements the

Re: best way to optimize a table with many to few relationship.

2003-02-04 Thread Alec . Cawley
If you have, and always will have, no more that 64 product types, you can store the product type in a SET field. This is effectively a hybrid between your list and boolean solutions. MySQL stores this as a bitmap with one bit per product type and provides the appropriate query methods. You can

Re: best way to optimize a table with many to few relationship.

2003-02-04 Thread Nicholas Elliott
I'd recommend a column of type SET. Read about it here: http://www.mysql.com/doc/en/SET.html Basically, if your list of product types is static, this may be a good bet. The SET type can store any combination of 64 members, stored as bits. To list all items int a product type, you might use