A
A
Alexey2017-06-30 22:02:19
MySQL
Alexey, 2017-06-30 22:02:19

How to store the quantity of goods?

Hello!
There is a table with products
products
- id
- name
And a table with colors
colors
- id
- name
- img
Some products may have several colors. And others may have no color at all. Where and how to store the quantity of such goods? That is, the quantity of goods of a certain color and the quantity of goods without color. I would like to keep everything in one place.
Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
jasonOk, 2017-06-30
@jasonOk

Create 3rd table product_colors:
id
product_id
color_id

It would be wrong to do so.
Why, it is said here: https://habrahabr.ru/post/193756/

E
Eugene, 2017-06-30
@eugeneledenev

That is, the quantity of goods of a certain color and the quantity of goods without color

Separate table name color price. More specifically, product_id color_id price to make selections faster.
And there is one more feature. Without color - this is also a color that will have its own ID

D
d-stream, 2017-07-01
@d-stream

Products?
Then store receipts (batch) and expense (write-offs), and calculate quantities.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question