HN Hall of Fame Weekly email

SQL Style Guide

www.sqlstyle.guide Reference Policies & guidelines Software engineering Class of 2024-11 Hall of Fame
Screenshot of www.sqlstyle.guide captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 5 calendar years, with breakout response in 2 of them.

submissions
5
submitters
5
observed span
2015–2024
peak thread · 146 comments
257 pts
latest 20+ return · 2024-11-15
56 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

Weird, I really dislike a lot of the suggestions. In particular, an example: SELECT first_name AS fn FROM staff AS s1 JOIN students AS s2 ON s2.mentor_id = s1.staff_num; We already agreed that staff is a good name for a table, so why are we renaming it to s1? There are all sorts of subtle bugs that arise when s2.mentor_id = s1.staff_num is wrong, and the variable names provide no help here that we're doing things right. How about: SELECT…

Familiarity makes consistency the only real guide in any formatting guide. So, apart from formatting rules, there are still a few bits to argue about. Try to use only standard SQL functions instead of vendor specific functions for reasons of portability. I don't think this is too important as the many places I've worked at had been using the same vendor for many years. Depends on your future plans, I guess. Include comments in SQL code where necessary. Use the…

deburo·59-point thread·

> Spaces should be used to line up the code so that the root keywords all end on the same character boundary. SELECT file_hash FROM file_system WHERE file_name = '.vimrc'; This style is annoying and I wish it gained less traction. It looks neat but it puts so much burden on the query writer, especially when you modify the query and all of the sudden you need to indent multiple lines just to make them all align. You know what's…

SPBS·56-point thread·

"Use a collective name or, less ideally, a plural form. For example (in order of preference) staff and employees." I hope Simon Holywell has never had to model a zoo in SQL. "Where are the rattlesnakes Simon - are they in the rhumba, crash or knot table?" [1] [1] http://blog.writeathome.com/index.php/2013/03/improved-anima...

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
2

100+ points or 50+ comments

Total points
391

reference only — not used in Hall rules or ranking

Total comments
240

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2015-07-24SQL style guide – a consistent code guide ensuring legible and maintainable codeTreffynnon1610
2016-10-09SQL style guideFirst breakout · Best threadokket257146
2018-09-06SQL Style Guideainar-g5916
2020-07-29A Style Guide for SQLjerodsanto30
2024-11-15SQL style guide by Simon HolywellHall induction · Latest 20+ point returnthunderbong5668