There is a task in general: there are tables with data (simplified)
- component table:
ид, параметр1, параметр2, параметр3, значение, количество - parameter1 match table:
ид, имя параметра, булево_значение (используем ли еще параметры для разбора)can be dozens of lines - Parameter 2 match table:
ид, имя параметраcan be tens / hundreds of lines - parameter 3 match table:
ид, имя параметраcan be hundreds / thousands of lines - pivot (if you can call it that) parameter table:
ид, ид_параметр1, ид_параметр2, ид_параметр3 - table of names:
ид, ид_pivot_элемента, имя
When outputting values from the component table, it is necessary to output the name from the table of names. The principle of building a table of titles is as follows:
- If by name we found parameter1 in the table of correspondences of parameter1, then we check the boolean value, if
truethen we take into account the values of parameter2 and parameter3 (iffalsethen nothing is done) - Next we find the ID of the mapping between parameter2 and parameter3, look for the full set in the pivot table, if we find it, then in addition to the data from the component table we derive the name from the table of names.
How correct is such a construction of logic?
Is it correct to constantly make a SELECT from the base to check the values, or is it better to make an array with all the values in advance and check through the array (since this will be in php - the memory on the array will not be much 2-4 columns per thousand values)?
Thanks in advance for your help, and I ask constructive criticism, and not just - "they do not do that"