Consider a table products
which has product details including its category. One product may belong to multiple category so I'm keeping it as a comma separated list of category IDs.
I know this is not normalized approach.
Can any MYSQL expert tell me that which approach will be faster for selecting products of a particular category.
Obviously we have to JOIN products
table and products_category_relation
table if take normalized approach.
AND
In my approach we have to write a like query to find the products (assume we are searching for category id 10)
SELECT p.*
FROM products p
WHERE p.category like '10'
OR p.category like '10,%'
OR p.category like '%,10'
OR p.category like '%,10,%'
Can any one tell me if this approach is faster or the JOIN approach will be faster?
I know about normalization. I know about other risks involved in my approach. But they do not matter in my case. So, I'm concerned with speed.
Any theoretical explanation about its speed or a practical test result are welcome.
UPDATE
I'm using myISAM engine
product table has Primary Key product_id
FullText index on category
column of products
table