Page 1 of 1

Dynamically building categories - where to start?

Posted: Sat Apr 02, 2005 8:30 am
by lyndonw
Hi

Im after some help because I can't figure out the best way to go about this.

I have 2 tables in a database, products and category_map.

In the product table is a comma seperated field for the categories (i.e. 234,345,567 - for multiple category entries).

I have seperated these using explode, but what I want to do is build a category list based on the names in the category_map field which relate to the numeric values in the product table. The category_map already holds the numeric values.

To complicate things the category_map has 3 fields, id, descr, and mastid.

id = the numeric value as in the products table
descr = description
mastid = master category id (for child categories)

Any and all pointers/tutorial links/code snippets would be most welcome.

Thanks in advance.

Lyndon

Posted: Sat Apr 02, 2005 8:55 am
by feyd
I would rebuild this comma seperated field into a seperate table you can JOIN your selection with. The major reason why is this situation, and your future database state. Imagine you have millions of categories. A "newer" (higher ordinal number) category will greatly limits the number of other categories you can attach with that product than if the product is apart of the "older" (lower ordinal number) categories.

The following may be of help http://www.oreilly.com/catalog/javadtab ... r/ch02.pdf