How Proektirovanie database?

Hello. Prompt on such question.
There are many many goods. Some of the goods - analogues, complete or partial other.
There are two tables. Table with these goods and a table brands. These two tables are related to each other through a third table.
I need to do to the article product was looking for its replacement or equivalent.
I understand the need to make a table of ratios where the two fields id_товара and id_его analog
For example item with ID 1 there are three analogue - turns out one item three entries. In this analogue the analogue product with the ID 1, and the remaining two goods. Already 6 records. In General, something I do not like the decision.
Maybe someone will suggest more elegant solution?
July 2nd 19 at 17:35
3 answers
July 2nd 19 at 17:37
you should not have taken to do online shop without proper training
And in fact, have something to say? - bianka commented on July 2nd 19 at 17:40
the part is the level of casinomania which you can assign the desired 0, 1 cross level cross level 2, and so on. When searching, you can adjust how gluboko should look for, as well as the cross can be adjusted to keep the parts do not overlap - lois.Gusikowski11 commented on July 2nd 19 at 17:43
how to understand "the Level of casinomania"? Take for example the two oil filter on one car. What is the level of casinomania? unit? A second level of casinomania will be part of the filter? And the third component parts component parts? Do I understand correctly? And then make a base with this level? - bianka commented on July 2nd 19 at 17:46
I mean counterparts
looking for article MAHLE kl9
the table of analogs example:
MAHLE kl9 -> 42540151A DUCATI
MAHLE kl9 -> 9153580680OE Peugeot
42540151A DUCATI -> FE1D317 BILSTEIN
BILSTEIN FE1D317 -> MAHLE kl9

when searching for MAHLE kl9 you get the position:
MAHLE kl9 - 0 level cross (unknown)
42540151A DUCATI - 1
9153580680OE Peugeot - 1
BILSTEIN FE1D317 - 2
accordingly, the level crosses to limit, not to seek more than 2 levels and so on, and also makes no sense to search for a product already found that there are a bunch FE1D317 BILSTEIN -> MAHLE kl9 kl9 proignoriruesh as MAHLE has already been found - lois.Gusikowski11 commented on July 2nd 19 at 17:49
July 2nd 19 at 17:39
There are two tables. Table with these goods and a table brands. These two tables are related to each other through a third table.

You have one item may have several brands?

I understand the need to make a table of ratios where the two fields id_товара and id_его analog
For example item with ID 1 there are three analogue - turns out one item three entries. In this analogue the analogue product with the ID 1, and the remaining two goods. Already 6 records. In General, something I do not like the decision.

Overall, this is quite normal practice, at least from the point of view of logic. For example, "light And" logically can be replaced by "light B", but reverse substitution may not be appropriate for some indications. Also, in this scenario, You will be able to sort the output by a unique degree of "recommendation rates" applying to each product and so on. But this approach definitely has shortcomings, in particular, this data redundancy, additional movements to add unparalleled in every product, extra disk space, bloating the database and so on.

If all the goods among themselves are absolute counterparts of each other, there is an alternative approach. It is that you create a group of counterparts, for example, in table analog_groups, every record where a = 1 group counterparts. Further, You indicate in the item, which group it belongs to analogues, it is possible to make both the group ID and its title (or any other parameter that You add) or option id_группы_аналогов any other product that is this group already included.

Features of this approach:
a) the Lack of data redundancy
b) All the goods in one group of analogues will always be analogues to all other products in this group
C) We will not need to do many of the same movements, constantly perelinkovat similar products from each other
g) Save the disk space and database size remains the same
d) We are unable to put a sort or the priorities of the output analogues for each individual product without harsh crutches
And if you combine the first and second option? Well, for example. Start linkowanie Talitsa, where the id field and unikalnyy. And set up another table. In the case of "hard link" to take data out of it? - bianka commented on July 2nd 19 at 17:42
: of course, you can do so. But as initially not specified key terms, what we want to achieve, to reduce queries and redundant data in the database, or to facilitate the work of contentwise that will the whole thing to fill. The option "to combine both" - will effect approximately 50/50, and he has a full right to life. - lois.Gusikowski11 commented on July 2nd 19 at 17:45
And Yes, one product can have multiple brands - bianka commented on July 2nd 19 at 17:48
: probably the first because contentsi to fill it will not. These data will be to collect the script. Roughly speaking. There is a parts store. Any spare parts is the concept of the catalog number (SKU), brand, description, and so on. Many articles are analogs or substitutes of each other. There is such as TecDoc database in which all this business to look. But... Not all TECDOC is. Many manufacturers with their proposals there, particularly domestic. Need the whole thing as something to look for. So I had an idea for the vendor to automatically collect data on analogues. But how to implement storage, then all this mess was convenient to use... - lois.Gusikowski11 commented on July 2nd 19 at 17:51
: I think the option of mixed data, i.e. take data and analogues from the group and as an addition - table with a list of counterparts for a particular product - quite a normal decision. Table "personal" analogues of each item will be minimal, and the table "vzaimoponimanii" commodities will have, respectively, the maximum amount of information. If the whole thing is filled with the script - I think many of the settings disappear by themselves, such for example as, sort by relevancy sales, and about other useful parameters, it is sufficient to be sorted, e.g., alphabetically. - bianka commented on July 2nd 19 at 17:54
July 2nd 19 at 17:41
make the field "analog" and all similar goods to fill it the same way.
choose a product and all products in which this field coincides with the field from the first product.
Hmm. An interesting decision in principle - bianka commented on July 2nd 19 at 17:44
the main thing - working. you can fill the field with the note: "reference" part. The only if some part of A which are analogous to parts b and C, but the part is not equivalent, then the logic will collapse. - lois.Gusikowski11 commented on July 2nd 19 at 17:47
: I think this should not be, therefore most likely this decision and use. And how better to communicate, do not tell? Linkowanie via a separate table or in the table item field for link to have? - bianka commented on July 2nd 19 at 17:50
: I would have started directly in the table. Take a digital field, it is the index and will work fast. - lois.Gusikowski11 commented on July 2nd 19 at 17:53

Find more questions by tags SQLMySQLWeb Development