I have a db that supports a free-form addition of values to products. I'm using a key-value structure because individual products can have wildly different key/value pairs associated with them, otherwise I'd just make a column.
Give a table for products and a table for key-value pairs, I want to know what kind of indexes to set up to best support this.
Tables:
- Products: productId(pk), name, category
- ProductDetails: productId(fk), name, value(text)
Frequently used queries I want to be fast:
- SELECT * from ProductDetails pd where pd.productId = NNN
- SELECT * from ProductDetails pd where pd.name='advantages' and pd.value like '%forehead laser%`