Friday, October 26, 2012

The Importance of Early Investigation

I will get back to the SQL for dummies stuff next time. This bit me in the ass this week in  my home life. The concept here can be applied to pretty much every aspect of your life. Two words: Do your fucking homework!

I got a frantic and exasperated holler from the kitchen this week. It seems the water was backed up in the dishwasher and what do we do! OMG! WTF! BBQ? Damn. So being the dutiful spouse (Ha! Whatevs...) I hop to it, grab some tools and pull the dishwasher apart and proceed to find nothing wrong. I double and then triple check everything. All is kosher. Spent quite a lot of time bailing water and looking for clogs and scratching my head and teaching the kids fun new cuss words. Ever heard a 4 year old shout "motherfucking bitch ass dishwasher!" and "what the actual fuck!". Did that really happen, you ask? No, no it didn't. But you can imagine, right? Nudge Nudge Wink Wink.

So, my exasperated and profanity laden evening would not have been wasted had I took a brief minute to check the simplest things first. Turns out my daughter was looking for a specific cup and it happened to be in the dishwasher, mid-cycle. A dishwasher that is humming and churning and leaking steam might deter the weaker spirited children and, perhaps, the brighter ones too. Not my daughter. She promptly unlocked the dishwasher and opened it mid-cycle to get her precious. Now, most of us would set things back to how we found them so whatever was happening and causing the aforementioned steam and churning business could continue. Alas, dreamy thoughts of iCarly, horses, milk and cookies, world domination, and "why is my brother such a douche?" were no doubt overwhelming and the washer remained unlocked and the poor cycle remained unfinished.

All of this effort, pain, suffering, effort, 'innocence bunker'-busting f-bombs, and effort could have been easily avoided. Experience is a bitch. It gives us bloated heads and fat honey boo boo's mama-sized egos. A complete novice might take some time to map out how things should work, what the normal process is, the happy path, and then devise a strategy of checking all of these in order of importance. However, it would be super easy for someone that has ever worked on a clogged dishwasher to assume that standing water means clogged drain and some of the time that would be correct. But only some. And some of the time ain't all of the time. 60% of the time it works every time is fine for Sex Panther cologne, Axe body spray, and Curtis's Valtrex but you don't want a 40% fail rate on your code or your condoms. You will have a bad time. So, do your Uncle DBDeveloper a favor and think just a smidge before diving in. Check the easiest shit first. That's why Service  Desk asks you to turn it off and back on. It's easy. And sometimes it fixes whatever shit the bed. Start with the simplest, easiest or quickest thing. Even if your gut is telling you it is super complex and what elegant solutions you might devise to resolve the problem. If your problem is an 8 year old girl with a penchant for obliviousness, how is an elegant solution for a mis-perceived root cause going to help? Two words: it fucking ain't.

I don't care how long you've been in the industry and how many lines of code you have written, If 60% of that was for the wrong reason, then I award you no points and may god have mercy on your soul. Seriously, check your goddamn ego at the door. Your boss doesn't give two shits how elegant a solution you can come up with for Problem B when Problem A is the one losing them money. Don't be stupid twat. Well, be as small a stupid twat as you can be. Not all of us can completely avoid the natural twattiness that is inside of us. I am ashamed to admit that even I, yes, I,  have a twatty streak, perhaps not quite a mile wide but certainly somewhere between Bree Olsen and the Octomom. I struggle everyday against this cursed twat gene. I am not sure which side I get the twat gene from - both sides exhibit such traits. Perhaps this is a curse of humanity. Perhaps there is a little stupid twat in all of us. Maybe if we were less concerned with skin color and income level and more concerned with reading books and staying fresh, the world would be a better place. Lik dis eff u cry evrityme.

But seriously, do your homework. When a problem comes along you must whip it, but first you must think what is the simplest thing it could be? Check that shit first. I could have had a lovely evening with video games, beer and internet porn but instead I was up to my elbows in half cleaned dishes and dishwasher parts.

I plan to get back on the SQL for stupid twats series again next week. Stay tuned.

Friday, October 12, 2012

What is a database and what is SQL?

What is a database? Well, it simply is a collection of data. How many of you are old enough to remember card catalogs in libraries? I know I am, but I am getting up there. How many of you have mothers? A few, I am guessing. How many of those mothers have recipe cards in a box or cookbooks on a shelf? Those are all databases, in essence. The IT version of a database is a little more complicated and can house shit tons of data. Every store, restaurant, gas station and school you have seen or been in, apart from some little mom and pop shops that are relics from a by-gone era, have databases that store information about the items they sell, the customers that buy them, the employees that work, etc.

Let's go back to the card catalog for a moment. A card catalog is a wooden dresser with lots of little drawers. Each drawer is filled with lots of little cards. Each card is filled with information about a book. Likewise, a database is filled with tables (drawers) and each table is filled with records (cards) and each record is filled with information about a specific thing (book). The way to get the information out of the card catalog is largely manual, although modern libraries have a computerized version of this that simplifies it a bit. You still have to get a piece of paper, jot down the Dewey Decimal number which is the location of the book and then walk around and find it. In a database, the method of retrieval is a bit different. Which brings us to our second question...

What is SQL? SQL or Structured Query Language is a method of inserting, modifying, or retrieving information from IT databases. ANSI-SQL is the industry-wide agreed upon terminology and methodology for interacting with data in a database. Each company has to make slight additions or change implementations a bit to provide value and/or differentiate themselves from the competition but the core is the same across all brands.

There are several different ways of getting data into a database and modifying data in a database, but the bread and butter of SQL is the SELECT statement. Let's say you are an IT guy and you built a recipe database for dear old mom. There will be a period of time where you, she or the whole family enters the data into the database. Afterwards, when mom wants to bake a cake, she will write a select statement. Now, depending on how advanced of an IT guy you are or how much you love your mother, you may mask the select statement behind a search box on a web page but the underlying mechanism is a SELECT. That statement might look like this:

SELECT * FROM Recipes WHERE recipe_type = 'CAKE';

This would return every record in the Recipes table that is for a cake. Simple, right? Sure, for Mom's Recipes, yeah, it is simple. Now think about a store like Home Depot? What might their database look like? What might a SELECT statement look like there? Well, it can get pretty complicated. What if your database was designed by a drunken water-head with extra chromosomes, parents that are cousins and no idea what a good database looks like? Queries in this behemoth make modern politics look sane and straightforward. I can only surmise that our DB architects mother was a willing participant because as we all know, if it was a legitimate rape, her body would have "shut that whole thing down". What a whore. I blame her for everything. With all the drinking she must have done in those nine months, I can't believe it went full term. It kind of makes me wish for a time traveling retroactive sterilization program that could nip that shit in the bud. The downside of that is, I'm pretty sure my Ex-wife would partake of that and my blogs would go poof into nonexistence. But, I digress.

SQL can be simple and can be very complex. But if it were always easy, everyone would do it, you know, like your mom.

Well, there you have it. Another installment from the angry database dude. I had so hoped I would avoid the anger and do a legitimate post, but people are stupid and they piss me off and my anger shut that whole legit thing down. Eh, maybe next time. And, as John Henson always says, Good night and big balls.