CS Trivia#7: Why is SQL shouting at me?
Tags: sql, watercooler, computerscience, todayilearned
Published: 2020-03-23 18:20:05

Welcome to my little CS trivia series. Every week I post a new trivia piece.

Today's question is...

---

## Why is SQL shouting at me?

In the times of online communicators, emails and texts, many people find SQL syntax a bit too aggressive.
![](https://dev-to-uploads.s3.amazonaws.com/i/ajtmkrvpk7908njzxuke.png)

Why is SQL not obeying the rules of netiquette? There are a few reasons. 

### Historical context

[SQL was created in 1974](https://en.wikipedia.org/wiki/SQL) when apparently majority of the keyboards did not have lowercase letters. Moreover, there were only [six bits available](https://en.wikipedia.org/wiki/Six-bit_character_code) to play with in character encoding, which is why languages like COBOL or FORTRAN also user uppercase. This was also the case with HTML (created in 1991), which initially had tags written in all caps until 2014 when [the standards and syntax were changed](https://www.lifewire.com/html5-tags-case-sensitive-3467997).

### Syntax Highlighting
This a bit aggressive syntax was kept for the purpose of [syntax highlighting](https://en.wikipedia.org/wiki/Syntax_highlighting). Back in the days, there were no fancy linters and so keywords weren't highlighted in any way when you wrote code. The SQL capitalization provides a quick and easy way to visually break up the different parts of the query, helping people differentiate between the SQL parts and the database objects parts of the queries. Joe Celko writes about it in [*SQL Programming Style*](https://www.amazon.com/Celkos-Programming-Kaufmann-Management-Systems/dp/0120887975):

> **Rule:** Uppercase the Reserved Words.
> 
> **Rationale:**
> 
> Uppercase words are seen as a unit, rather than being read as a series of syllables or letters. The eye is drawn to them, and they act to announce a statement or clause. That is why headlines and warning signs work.
> 
> Typographers use the term bouma for the shape of a word. The term appears in paul Saenger's book (1975). Imagine each letter on a rectangular card that just fits it, so that you see the ascenders, descenders, and baseline letters as various "Lego blocks" that are snapped together to make a word.
> 
> The bouma of an uppercase word is always a simple, dense rectangle, and it is easy to pick out of a field of lowercase words.

### Keywords avalanche
Important to add, SQL has [a large number of keywords](https://www.postgresql.org/docs/8.1/sql-keywords-appendix.html) and relies on the reader's ability to distinguish keywords versus identifiers in order to mentally parse the syntax. How does this relate to the capitalization?

Research has proven ALL CAPS is harder to read, so much so that the USA Federal Highway Administration has mandated the use of mixed-case signs in their [Manual on Uniform Traffic Control Devices](https://mutcd.fhwa.dot.gov/pdfs/2003r1/Ch2D.pdf)(2003), which states:

> The lettering for names of places, streets, and highways on conventional road guide signs shall be a combination of lowercase letters with initial uppercase letters.

The [New York Post](https://nypost.com/p/news/local/bronx/million_kuj8X4Z2VolVhXnCymfkvM#ixzz1124jAn1q) also adds:

> Studies have shown that it is harder to read all-caps signs, and those extra milliseconds spent staring away from the road have been shown to increase the likelihood of accidents, particularly among older drivers.

---

I personally like angry-typing SQL when I'm frustrated with e.g. prolonged quarantine. **While at it, check out this amazing [SQL exercise series](https://dev.to/zchtodd/sql30-day-1-wildfires-2b02) by [zchtodd](https://dev.to/zchtodd)!**