What Counts for a DBA – Decorations

I was whistling contentedly as I hung up the Christmas Decorations. It may have been ‘Jingle Bells’, or it could have been ‘Santa didn’t buy me a bow-wow’: Christmas songs are creepily similar. As I hung up the lights on the Christmas tree, I was struck by the thought ‘Decorations are not decorations at all, but a communication’. I stood back to inspect critically what I’d done and hurriedly drew the curtains together before someone realized just what a nerd I am since half of my ornaments are Star Wars, the other half Legos, and just a few are of sentimental or spiritual origin.

As DBAs, we are called on to write a lot of code. Code to do stuff such as schedule jobs, backup databases, create databases and objects like tables and stored procedures, create and give security to principles, query data, and many other tasks. While none of these tasks is exactly like the other, they all share a common problem. When we get back from celebrating Christmas and/or the New Year, having eaten and drunk our weight in Egg Nog, we need to remember what the code does. This is where decorations come in: they are there to communicate. Just like you can get an idea what a person is celebrating from their Christmas decorations, you can tell a lot about a person’s code by looking at how they decorate their code in three particular ways.


SQL code is amongst the worst code to parse by a human without proper formatting. The following line of code is actually multiple statements that would work:


However, it is far better to write:


The code is still gibberish, but now it is readable gibberish that we can see approximately what is going on. But we are not finished decorating this code.


Now we need to give better names to objects. My names are clearly terrible. So let’s apply a bit of better naming:


Ah, now it is a bit clearer that we are doing something with a tree and ornaments. From the names, I can see that we are deleting ornaments from a tree, apparently based on size… But why? One last bit of decoration to add



Now the reader of this code can easily tell what this code does, why it does it, and use accordingly. Nothing we did changes the functionality whatsoever. With a little work, we could figure out the format using a tool like SQL Prompt, and we could figure out from the data that O was ornament, and T was tree, and what all of the code actually does.

But you will thank yourself for decorating your code when you come back from a well-deserved break… And even better, you will never need to take these decorations down!

Wondrous Celebrations of these Holidays to you and yours. See you next year!