Improve how LatticeSuggester deduces foreign keys.
Currently LatticeSuggester uses SqlStatisticProvider and deduces that a join between two tables is "many to one" if the left table has more rows than the right table. Clearly this is wrong, because it does not take into account the keys of the join.
I think we will change the method
and add a method
For example, isForeignKey(empTable, ["DEPTNO"], deptTable, ["DEPTNO"]) would return true.
One valid implementation might look at the catalog for foreign key constraints; another might execute a query to see whether every row in emp is matched by exaclty one row in dept. Here is a query that might do it:
If the query returns any rows it is not a foreign key.