3 ms·
No, my concern is not that you can also specify the table name that explicitly states the name of both tables, it's that you have proposed a syntax where it is
by hn_throwaway_99 5y ago
No, my concern is not that you can also specify the table name that explicitly states the name of both tables, it's that you have proposed a syntax where it is possible to leave off the explicit table name.
If you got rid of the syntax that uses the underlying "magic" of needing to know which table the foreign key points to, I'd be more amenable.
- JoelJacobson 5y agoThere are two asymmetrical cases; one of them needs two pieces of information, the other three. Having to always specify both tables would syntax wise be redundant, but I agree it’s worth considering it might be a good thing to improve readability, which would help especially in the case where the foreign key isn’t/cannot be given the same name as the referenced table.
- mrweasel 5y agoYeah, my concern is people in the real world. If you can "magically" join on a foreign key and leave the table name out, or still call the thing anything you want, some smart ass will abuse the live crap out of it and I'll somehow be left to deal with it. I like things to be explicit. Tell me what you're joining and how you want to join it. What is the use case for this? Other than saving some typing, and let's face it, sometimes a little extra typing now, will save you a lot of trouble later. The proposal claims: "The idea is to improve the SQL language", but is it really better?
- tapas73 5y agoFirst, very valid concern regarding table name. > Other than saving some typing, I would like to point out the corectness aspect of the proposal. Today foreign keys are enforced during inserts, updates, deletes. (you just can't violate fk. this is so good) But you can violate it in selects. (e.g. mistype column name, forget to include a column) This proposal (or its adjustment) would allow to use fk also during select. It's like static typing for join conditions.
- hn_throwaway_99 5y agoIn my entire software development career, I've never had that problem, nor seen it. Sure, I've mistyped a column name or left one out. But the failure is then nearly always so catastrophic (the query failed to compile), or the data response then so different from what I'd expect (pages of results instead on 1) that it's not something I've seen that needs fixing.