P
P
Pepelas2018-11-21 16:46:12
MySQL
Pepelas, 2018-11-21 16:46:12

How to link five tables with repeating elements through Yii2 intermediate table?

Hello, please tell me how to solve this problem.
There are 5 tables in the database connected through an intermediate.
5bf561893d497400840221.png
The relationship hierarchy is as follows:
auto->auto_model (one-to-many)
auto_model->auto_group (one-to-many)
auto_group ->auto_description (one-to-many)
auto_description-> auto_action (one-to-one)
auto_description -> auto_coast (one-to-one) Putting
all records into one table results in about 60,000 rows.
In order not to produce records of the same type, records are not used in the auto_group, auto_description and auto_action tables. That is, milestone models will have a group of "suspension elements" and each such group will have a description of "steering rack linkage" whose action is "replacement". Because of this, I can't link tables directly. Moreover, the connection breaks when auto_group -> auto_description is selected, because all occurrences of this group are selected from the auto_bind table, which may not match, for example - auto_model-> id = 3.
Cool question: how can I make the binding of YII models with minimal system resources?
If not - then tell me how to properly organize the database?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2018-11-21
@Pepelas

In order not to produce records of the same type, records are not used in the auto_group, auto_description and auto_action tables.

And what will you win besides the size of the base? Requests become more complex and slower. I think this is a very strange idea.
In general, as soon as one-to-one appears, it is most likely a crutch-crutch
funny number. I understand when it comes to 60,000,000 lines, then you can look for something to save, and then there will be different methods. And in your case it is necessary to do more simply and more obviously, namely all that one-to-one to push in one table.

P
Pepelas, 2018-11-21
@Pepelas

The main idea is that when adding a new one to the catalog, you can use the existing one, if appropriate.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question