Suppose you are designing a searchable database for a webstore, and have a situation like the following:
Each product
will have multiple, different categories
.
For example, consider a MARKER as a product
.
E.g.: The same MARKER might have as its category
all three of the following:
- TOY
- SCHOOL-STATIONERY
- ART-ACCESSORY
Now, each category
has a corresponding set of any number of parameters (let's call them features
) that apply only to that category.
Thus, for each of its three product-category
representations, the MARKER above will have multiple, different product-feature-names
and respective product-feature-values
.
E.g.: We might have these category-based feature-names
and product-specific feature-values
:
- PRODUCT-NAME::: CATEGORY-NAME::: Feature1-name = Feature1-value, etc.
- MARKER::: TOY::: AgeGroup = 6-12, Toxic = No, ChristmasSpecial = Yes
- MARKER::: SCHOOL-STATIONERY::: BulkAvailability = No
- MARKER::: ART-ACCESSORY::: Use = Fine-drawing, CompatibleSurface = All
What would be the best / most-optimal design for this type of situation?
My thought is to use three tables, but I don't know if this is the most efficient for retrieving data later (perhaps this should be done in two tables, or even just one?):
PRODUCT-TABLE
id, product_name
CATEGORY-TABLE
id, fk_product_id, fk_category_name
FEATURE-TABLE
id, fk_category_id, feature_name, feature_value