Following on from the last page, we take the next step to build up the dimensional analysis query.
Continuing with f=ma as an example, and building on the exercise from Query 14.10, we repeat the analysis for all relevant dimensions (mass, length, time). If any of these fail to balance, then the formula fails. Finally, we invert this result, to find the formulas that pass the dimensional analysis test.
The queries in this section are based on the following data sets:
Since you did the exercise at the end of Query 14-10, this should come as no surprise. Using another VALUES definition, we iterate over all the dimensions we wish to analyze, and see the balance of the formula in each dimension. Already at this point, we see that the formula balaces.
A formula fails if any of the dimensions fail to balance. We aggregate with GROUP BY ... SUM, then filter with HAVING, to find the formulas that fail; that is, any of the dimensions fails.
To pass dimensional analysis, we need to negate this result. We do this by putting a FILTER NOT EXISTS around the whole thing. This query returns TRUE if the formula passes, FALSE if it fails.
A few things to think about: