I have a basic product table in my database
The table records most of the value of a product common to every product like the price, mrp, name, sku etc.
Now every product has a few different attributes not applicable to each product. A shirt has size and colors, a monitor or cell phone has different display resolution, a book has ISBN and an author name so on and so forth
I need to have these attributes as well. Can anyone please give me a hint on how it can be done.
I have gone through a few question on stackoverflow and google but could not figure out how to do it right or else I wouldn't risk myself being down voted on stackoverflow.
Plan A:
Step 1. Decide on which fields will be used for searching or sorting.
Step 2. Shrink the list from Step 1 down to no more than, say, 5 fields. Pick the most useful.
Step 3. Create a table with those 5 fields, plus one
TEXT
field for aJSON
collection of all the miscellany data about the items. (It may as well include the 5.)Step 4. Build composite indexes that will handle many (but probably not all) of your common queries.
More discussion -- mostly about why EAV is bad.
Plan B:
Convert to MariaDB and use its "Dynamic columns" and other techniques, including indexing fields in JSON text.