by ZenoArrow · 10y ago · 0 comments
As for the indentation after FROM, I prefer to put an indent here too. Whilst you're right that INNER JOIN would have the same priority, LEFT JOIN wouldn't, and I wouldn't want to use different indenting styles for different types of joins.
That said, I don't agree with everything in this style guide, especially...
* Do... "Try to use only standard SQL functions instead of vendor specific functions for reasons of portability."
* Avoid... "Descriptive prefixes or Hungarian notation such as sp_ or tbl."
With the standard functions, it strikes me that's optimising the wrong thing. How many times are you likely to switch database engines? Such actions are very rare, especially for teams with good grounding in RDBMS'. What's more important to me is readability of the code, and there's plenty of useful non-standard SQL for improving readability. If we want both we should be pushing for updated standards to be applied across the board.
As for the second point, it's useful to know whether you're looking at a table/view/function/stored procedure/trigger from the name alone. Whilst the tbl prefix seems superfluous, other database objects should have a descriptive prefix in the name IMO.
This isn't memorable: staff and students both start with st!
Lastly, if someone did have poor memory they could lengthen the aliases to STA and STU.
Better :) But I prefer to just give my tables short names to begin with. How about staff and pupils? That's so short that there is little temptation to abbreviate.
Not often, but you may wish to support multiple engines at once, and it makes your code a lot easier to manage if you don't have to have a separate set of queries for each engine.