SQL style guide by Simon Holywell
11–20 of 76 posts
Re: SQL style guide by Simon Holywell
#12I’m probably alone in this, but I dislike naming tables in plural. IMO, reading “SELECT employee.first_name” makes much more sense than “SELECT staff.first_name”.
Re: SQL style guide by Simon Holywell
#13Re: SQL style guide by Simon Holywell
#14Re: SQL style guide by Simon Holywell
#15For comparison, here’s Mozilla’s SQL style guide: https://docs.telemetry.mozilla.org/concepts/sql_style
Re: SQL style guide by Simon Holywell
#16I’m probably alone in this, but I dislike naming tables in plural. IMO, reading “SELECT employee.first_name” makes much more sense than “SELECT staff.first_name”.
join users as user on user….
Then do as you please without the that if you are dealing with a user or leave it plural if multiple…
And if we’re talking personal preference I really dislike caps in reserved words in sql, even before highlighting was everywhere it still just feels archaic for no good reason
Re: SQL style guide by Simon Holywell
#17I’m probably alone in this, but I dislike naming tables in plural. IMO, reading “SELECT employee.first_name” makes much more sense than “SELECT staff.first_name”.
Re: SQL style guide by Simon Holywell
#18Shifts my focus away from the rest of the query.
Re: SQL style guide by Simon Holywell
#19I‘m not a fan of upper case keywords especially when there is also syntax highlighting that gives them a unique color. Shifts my focus away from the rest of the query.
Just like I don’t like uppercase paragraphs because of the same reason
Re: SQL style guide by Simon Holywell
#20Not bad advice. The one about “where possible avoid simply using id as the primary identifier for the table” stood out to me. In the past with multiple ORMs (ya, ya, we all hate them) the default was to map to a column named id. Also when doing joins its cleaner to use the table_name.id or alias.id then table_name.table_name_id or alias.table_name_id or whatever else besides id is used. The best is when multiple peop…