Twitter

Follow SQLQuill on Twitter

Subscribe

MN Pass

T-SQL Tuesday #008: Learning to KISS

TSQL2sDay

This month’s T-SQL Tuesday, “T-SQL Tuesday #008: Gettin’ Schooled” is hosted by Robert Davis (Blog/Twitter) aka the SQL Soldier.  The topic is: How do you learn? How do you teach? What are you learning or teaching?

I usually try to teach others the same way I learn – a bit of theory and lots of hands on examples.  Mainly though I always try to “Keep It Simple” or “Keep It Simple, Stupid” – aka K.I.S.S. I’ve always loved the idea that a genius can take a complicated situation and make it simple.  How many times do we take a simple situation and make it complicated?  That’s kind of the opposite if you ask me.

The Setup

When I’m teaching someone I always remember the words of a football coach I had, Dennis Raarup.  ”Keep It Simple – Stupid!”  When he’d ask what coverage the defense was in, a hot shot young kid would say something complicated like “Smash – Man Free with a Monster”.  Coach Raarup would yell back, “No – Are they chasing the receivers or checking off?  If they are chasing them, it’s man coverage and we need to keep moving.  If they are checking off, it’s a zone and our receivers need to settle in the holes.”  That was his views on the passing game – it was that simple.  He could take a complicated situation and break it down to running or settling – the rest was easy.

Back to SQL, when I’m teaching someone somthing, I always try to keep it as simple as I can.  I always take the situation to a test server, create a database named Test, create a table named Table1 with column 1, column2, etc.  I then create the other objects to mimic the situation’s trouble spot.  It’s amazing what you can recreate quickly and easily on your local machine and how obvious the problem becomes when it’s table1 outer joined to table2 using column1 from both tables instead of the Incident table outer joined to Contact on SecondaryContactLastName and ContactLastNameID.  Not only can you simplify complicated situations, but you can also identify and investigate the actual problem instead of getting wrapped up in the details of the real situation.  Instead of “it doesn’t work”, you can explain that the process is missing a step or the code needs to include a where clause, etc.

Another benefit to working on a test server in a separate database is as I like to say “Russian roulette is not the same without a gun“.  That means that it’s a much safer environment and if you mess up – which is a great way to learn – you won’t stop 30 application developers from meeting their deadline.  I always try to build up the scripts and save them so if something goes awry, you can drop your test database and easily recreate the situation. Here is an example of the start of one:

/*
--------------------------------------------------------------------------------
--  Test database create scripts                                              --
--                                                                            --
--  Note this DROPS the database and recreates it                             --
--                                                                            --
--  Created by Andy Lohn of www.sqlfeatherandquill.com                        --
--------------------------------------------------------------------------------
*/
USE [master]
GO
IF  EXISTS (SELECT name FROM sys.databases WHERE name = N'Test')
DROP DATABASE [Test]
GO
CREATE DATABASE [Test]
GO
Use [Test]
Go
Create table Table1 (column1 int identity(1,1),
column2 datetime)
Go
Insert Table1 (column2) Select GETDATE()

The Payoff

I recently used this technique with a soon-to-be junior DBA here.  He was running some tests trying to get test data ready.  I showed him how to randomly create data and populate a column (this situation inspired this random data post).  I didn’t give him too many specifics, but showed him the idea.  About seven emails later that day from him – he was quite excited, he had figured out he could set up all his test data in multiple tables like this and what normally took him a day of manual data entry, now took him less than a day to do initially and now will take him less than an hour for any test coming up. Situations like this is why I started this blog – to help people do things I know are possible and I know will help.  This is also why I need to teach and have an impact on people – like Coach Raarup had on me.

Coach Raarup

4 comments to T-SQL Tuesday #008: Learning to KISS

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>