I
I
Ibishka2020-07-09 14:20:45
MySQL
Ibishka, 2020-07-09 14:20:45

How to design a database for an online store?

They say you need an env scheme, it’s not clear how to make a structure if one product has several colors and the colors can have several product sizes, how to connect it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VicTHOR, 2020-07-09
@Ibishka

one product has several colors and flowers can have several sizes

Something like this:
product
id | article
color
id | hex_code | rgb_code
size
id | rus | eu
offer
product_id | color_id | size_id | count

M
Maxim, 2020-07-09
@Tomio

Well, in fact, you have nothing complicated. You need 3 tables:
1. Products
2. Product properties (color, size)
3. Linking table, where you refer to the first 2 tables with foreign keys.
Thus, you implement a many-to-many relationship (many-to-many) .
Schematically, it looks like this:
5f0711dd26ce5470607139.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question