Here is my scenario
Table 1: GID || Info1
Table 2: GID || Tb1GID (refers
to GID of Table1) || Info2Table 3: GID || Info3
Table 4: GID || Tb2GID (refers to
GID of Table2 || Tb3GID (refers to
Table3 GID || Value
Now I have to build an sql query to get the value, given a particular Info1, Info2, Info3.
Essentially, I have to get the GID, of table 1 using info1, GID of table to , by mapping info2 and GID of table 1. And then get the GID of table 3 using info 3. And combine these to GIDs to get the value in table 4.
What is the most optimal way of constructing an sql query for this one?
Just join the tables on the id:s and match the info values in the condition:
This communicates most clearly how the relations work, giving the query planner the best information to work with.