or use subquery
Nov 8, 2021
1
Level 1
How would you handle if there's a field need to be calculated but need go through few relationships?
I have a question on calculate a count of field or sum of field when i need go through about 4 tables to get the results. For example, table1, table2, table3 and table4.
The relationships defined as table 1 has many table2 table2 belong to many table 3 table4 belong to many table3
When I am queuing table1, I need to count or sum needed field. from table4. In this circumstances, how would you handle it?
Will you create a field name field_count or sum_of_field in table1? And then use cron job to update the field in table1.
Or using relationship to get the total every time when query executed?
Please or to participate in this conversation.