4 ms·
> and annoying to do the correct thing (joining on the defined foreign keys). Maybe you’ve seen this thread already; a proposal with some alternatives on how t
by JoelJacobson 5y ago
> and annoying to do the correct thing (joining on the defined foreign keys).
Maybe you’ve seen this thread already; a proposal with some alternatives on how to improve the situation for joining in foreign key columns, but in case not here is the link:
https://news.ycombinator.com/item?id=29739147 https://news.ycombinator.com/item?id=29739147
- faho 5y agoThat proposal unfortunately requires you to name the foreign key constraint, which is quite unergonomic. E.g. instead of the wrong `FROM a NATURAL JOIN b` you would use the correct `FROM a JOIN FOREIGN a.foo_fkey`, which not only needs that second name but now also loses the immediate naming of b. So e.g. autocomplete would have to look up the foreign key constraint to find out the second table. And it's still longer and harder to use than the natural join! Most databases have one foreign key from a given table to another given table, and that simple case should be made easy to use.
- JoelJacobson 5y agoThere are multiple alternative syntaxes suggested in the proposal, one of them doesn’t use foreign key names, but instead the foreign key column names, similar to USING (), but without the ambiguity: https://gist.github.com/joelonsql/15b50b65ec343dce94db6249cfea8aaa#join-table_name-foreign-fk_column_name--from-referencing_alias--to-referenced_alias https://gist.github.com/joelonsql/15b50b65ec343dce94db6249cf...