-1

I need help with Product Variations. I haven't started anything yet, so I don't have an example because I don't know where to start. I will make a small sketch of what I think it should look like, and anyone who has experience with this category would help me a lot.

Database structure:

Color

|   id   |   Color Name   |   Product ID   |
|    1   |     White      |        1       |
|    2   |     Black      |        1       |

Size

|   id   |   Size Name   |   Product ID   |
|    1   |     XXXL      |        1       |
|    2   |     M         |        1       |

Product

|   id   |   Product Name   |   Product Size   |   Product Color   |   Product Description
|    1   |   Jacket         |        1,2       |        1,2        |     Jacket.....    

Because I have never done product variation before, I want to get information on whether this method is correct or not? Share with me your opinions, and experiences on how to do it in the best possible way

user3783243
  • 5,368
  • 5
  • 22
  • 41
Lauren
  • 35
  • 5
  • 1
    This is a good [read](https://stackoverflow.com/a/19200349/231316), along with most answers in that thread, and the ones that talk about SKUs – Chris Haas Jun 27 '22 at 00:14
  • Most of the taggings and technologies mentioned here are unrelated. This is essentially a db schema question, right? I added `group-by` as a tag as well because you'd want to do that but there's no PHP nor PDO relation. – user3783243 Jun 27 '22 at 00:16

1 Answers1

0

Use a mixture of columns and JSON.

The columns should be items that are typically searched on. Index the columns.

The JSON column contains the less common attributes -- For example, only dresses have a "dress size", only cameras have an "F-stop".

Have MySQL search on columns; have the app finish the filtering by checking the JSON.

More: Entity-Attribute-Value

Rick James
  • 135,179
  • 13
  • 127
  • 222