-2

i am working on an ecommerce tables and i came across variations where i didn't know how should it done lets assume those are my mysql tables db

my question is for example

I phone 14 pro max have diffrent storages 128 and 256 and a diffrent prices ( not same as colors ) (in the end all of them are related to variations ? or when its diffrent prices it should be diffrent product_item) ? doesn't that break the rule of not repeating thing ? how do i handle that ?

btw the place i get this database design is from here:

Youtube: https://www.youtube.com/watch?v=1HamqOuv2Cw

Saybers
  • 39
  • 5
  • Does this answer your question? [How can you represent inheritance in a database?](https://stackoverflow.com/questions/3579079/how-can-you-represent-inheritance-in-a-database) – philipxy Apr 24 '23 at 15:19
  • What is your 1 (clear specific) question? PS Put all & only what is needed to ask in your post, not just at at link. Don't expect us to watch a video let alone read another page. Paraphrase and/or quote with credit what is relevant & relate it to your post. [Why should I not upload images of code/data/errors?](https://meta.stackoverflow.com/q/285551/3404097) An ERD is an image of DDL. In code questions give a [mre]. This question is (clearly) a faq. Research is expected & duplicates of very duplicated questions are poor posts. Please use standard spelling & punctuation. [ask] [Help] – philipxy Apr 24 '23 at 15:27
  • Does this answer your question? [Modeling Product Variants](https://stackoverflow.com/questions/24923469/modeling-product-variants) – user1191247 Apr 24 '23 at 17:29

1 Answers1

0

Beware of "over-normalization". It seems like the name and value of a "variation" could simply be columns in the table that needs them rather than having two more tables for them.

Write out the main SELECTs for the schema you have, then try to write out the equivalent SELECTs for my suggested simplification.

If you need to search on various attributes of a product, consider throwing all the attributes (variations) into a single column and create a FULLTEXT index on that column. MATCH...AGAINST... is very efficient, when it is appropriate.

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • No because its one to many relation between the variation name and the values for example color can have 4 values red,blue,green – Saybers Apr 25 '23 at 09:49