Category: SQL

SQL Formatting

Let's standardize how we write SQL. What joy. Rarely, have I seen consistency in how SQL is formatted, and often it is not even considered. Here is the standard I use which makes it easy to read both simple and complex queries. Here is an example: select b.id…

database, Elegance, SQL

Read article →

Variable Naming Conventions

A simple rule to help improve convention and maintainability: Camelcasing should be used when dealing with Objects, Everything else should use underscores. Objects Class definitions should be CapCase Objects should be mixedCase Class Methods should be…

Design, Elegance, SQL

Read article →

Why SHOUT in your SQL?

Somewhere someone started the tradition of capitalizing keywords in SQL. Its like shouting all the unimportant parts of the code and making what's important harder to read. SELECT b.id as book_id, a.name as author, b.pub_date as publication_date FORM books b…

Design, SQL, Uncategorized

Read article →

Take some lines

Do you ever want to take some lines from the middle of a file say, lines 300-400? You can do that in a kludgey way with Unix head and tail: cat ids.csv | head -400 | tail -100 The take command from vbin tools does just that. cat ids.csv |take 300 400 Here we…

Command Line, SQL, Unix

Read article →