Answer the question
In order to leave comments, you need to log in
Online store. How to store product varieties in the database?
I design a database for an online store. There is a need to store information about similar products. For example, the package may be 100, 200 or 500 grams. The taste can be chocolate or strawberry. Accordingly, the descriptions will be identical, but the prices and quantity in stock will be different. In the catalog, the product must be represented by one item with a set of options. How to store all this in the database?
Answer the question
In order to leave comments, you need to log in
Move the properties to separate tables (using them to do product filters later).
Make a table for linking goods and properties, add the price, stock balances and the availability of a position for sale to it (if, for example, information from suppliers is analyzed).
Plus ambiguous work with such basic parameters as "price", "quantity".
I did this on one of the projects:
product_category
product_group
product
product_attribute
product_attribute_value
Perhaps the product_group will be redundant, but in my case it was necessary (the specifics of the product).
Actually the problem is as follows: there is a table of goods, there is a table of properties for them, let's say we search by properties and find 1000 different id of goods - pull data from MySQL apparently in this way (SELECT * FROM goods WHERE id IN (array)), where array is an array out of 1000 elements - perhaps everyone will agree that such a request with store attendance of even 1k users per day and with a table size of at least several tens of thousands of products - destroys the system, how much in vain.
The solution with the storage of goods in alternative databases is not considered (since, in document-oriented databases, such a request will be processed in a constant time). It would be desirable to hear options with MySQL.
PS all of the above are just varieties of the obvious, nothing more, especially the laid out database dump - too many beeches;) but in fact exactly what I described above :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question