Hacker News new | ask | show | jobs
by marcosdumay 3729 days ago
I never understood why the thing named "natural join" don't use relationships to determine the joining columns. Does not look natural for me.
1 comments

Indeed, this is also what always annoyed me.

I suspect that this has to do with the fact that NATURAL JOIN is intended to work for sub-SELECTs and VIEWs, too. On those, it is quite hard and error-prone to determine "foreign key" equivalents.

Also note that restricting NATURAL JOINs to tables wouldn't be a good solution here, either, because that would prevent you from ever JOINing more than 2 tables: When JOINing 3 tables, you effectively do have some kind of sub SELECT after having joined the first two tables, which is then supposed to be joined with the third one.

You get the same sort of problems jessedhillon was talking about.

That is, you lose absolutely nothing - just changes its semantics.