H
H
hbuser2014-08-25 15:47:11
MySQL
hbuser, 2014-08-25 15:47:11

How to organize the database structure for storing goods of an online store?

I have a "goods" table. Each product can have common attributes (article, price, name, ..., - all those characteristics that are the same for all products, regardless of their type) and individual attributes (such as weight, color, memory size, etc.). ) All common attributes are in the "goods" table. The individual attributes are in a separate table "individual_attributes". I also have a "attributes_group" table. In it, I form peculiar patterns from attributes (processor, carpet, phone, pen, etc.). Then I assign the product to one of the groups. Thus, I have something like a constructor for generating a template for any type of product and adding it to the online store.
goods -> (many-to-one) -> attributes_group -> (many-to-many) ->
Everything seems to be fine, but I still need to add attribute values ​​​​for each product somewhere. I thought to do this: I create a separate table "individual_attributes_values" with a many-to-one relationship with respect to the "goods" table.
goods -> (many-to-one) -> individual_attributes_values ​​(2)
In it, I could store the values ​​of individual attributes for all products. And I would take the information like this: I make one request to assemble the attributes ("framework") for this product to a bunch of tables (1). Then, in a loop for each attribute, I take its value from the bundle (2). But in this case, there are many requests. And I would like to collect everything in one ORM object with one request (I use Laravel). Any thoughts on how best to organize the database? This is all despite the fact that for each attribute (individual_attributes) there may or may not be a list of fixed values. Those. if it is, then you can not add anything other than these values. If they are not present, then the value is given by arbitrary text. Plus to this - then on top of this you need to implement a faceted search (elasticsearch or sphinx).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav, 2016-03-20
@stascer

My implementation on MySQl and Sphinx -
blog.yamaker.ru/20-facetnyy-poisk-filtraciya-obekt... .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question