Answer the question
In order to leave comments, you need to log in
How to store such data in the database?
Hello! There is a product (vertical blinds), which, depending on the width, may have a different number of slats (strips of fabric), which can be of different colors and different lengths. Items with general information are stored in a database table. What is the best way to store information about lamellas?
Answer the question
In order to leave comments, you need to log in
Изделие
: code, description. Состав изделия
: product code, lamella code, lamella number (that is, what it is from left to right). Ламель
: code, length, color code. Цвет
: code, name.
And this is assuming that all the lamellae are of the same width.
Table with colors ( table_c )
id, (fields with color description - name, standard, etc.)
Table with description of lamella ( tabel_l )
id, (fields for describing lamella: height, etc.), color_id - this is it field refers to the color
table Product table ( tabel_p ) - what you have
id, lamel_id - field refers to the table of lamellas (tabel_l), count_l - number of lamellas, (other fields for product description: width, height)
did you look at the dependencies?
table of names - the main one
(there is the main price per unit of measure)
and an
additional
table
of length, a color
table
, etc.
Break everything into separate tables:
- Blinds table: id, description
- Length table: id, length value
- Colors table: id, color value
- Length-Colors-Blinds table: blinds id, length id, id, colors (connecting table, make all 3 columns unique so that there are no repetitions of options)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question