What is a Transaction?
OK, Hive Mind I have an assignment for you. As I plod through the edit phase of my Performance Tuning with SQL Server DMVs book I’ve been asked by my Overlord PITA Task Master Editor to explain what I mean by Transaction when used in discussing the sys.dm_tran_ … Dynamic Management Objects. Of course we’ve all memorized the definition from Microsoft Books Online and our Microsoft Certified Training courses…
“A transaction is a sequence of operations performed as a single logical unit of work. A logical unit of work must exhibit four properties, called the ACID (Atomicity, Consistency, Isolation, and Durability) properties, to qualify as a transaction…”
Then we all go on to explain what ACID means in detail…
Atomicity means that a transaction either completes all it’s necessary data modification in full, or rolls back in full.
Consistency asserts that when transaction finishes, all data and supporting structures (think indexes) meets all rules that were put in place for the data (foreign keys, default constraints, etc.)
Isolation denotes that a transaction is independent, isolated, and without impact from any other concurrent transaction active on the instance at the time it’s being processed.
Durability requires that the effects of the transaction are persisted once completed, even in the face of system failure.
There, we all have the clinical definition in front of us that we learned fresh into our SQL Server careers.
Your Challenge
Now, my task to you Dear Reader is how do you describe a transaction? How would you explain it, in a non-technical fashion if asked by a coworker, manager, editor, child, spouse, hobo, clown, etc.? Not that I’m saying my Editor is a childish clown that may or may not ride the train systems in Great Britain eating beans from a can. Quite the contrary. Be creative. Be accurate. Be funny, serious, or obscene, but be non-technical. Your words, credited to you, may make it into the book. If you wish to remain anonymous in the book, please simply state that in your comments on this post.
A transaction is a set of statements that are grouped with the intention of being executed together – either the entire set succeeds, or the entire set fails.
I think that a grocery store analogy might work. You go in with a shopping list of items to buy and collect them together, but you haven’t committed to purchasing them until you go to the checkout counter and swipe your card. If you want to go further, triggers could be related to those last minute changes you make to your cart when you are checking out, as you review you items and add in things that you forgot to include.
I had this challenge myself with relatives. I usually only focus on the Atomicity (without actually saying it) and I talk about a bank transaction like that of transferring funds from one account to another. Money comes out of account A and goes into account B… We subtract an amount from A and add an amount to B. If both succeed Good. If both fail, not so good, but okay. We never want one to succeed and one to fail.
That was enough to continue with the story I was telling. It’s not the whole picture, but i wa’s enough.
[…] read. I know, I re-read it before publishing. Well blame it on Tim Ford (blog | twitter) and this challenge. Tim asked, what is a transaction? How do you explain it in a non-technical way? He said […]
How about this? 🙂
http://janiceclee.com/2010/06/22/transactions-and-oh-yeah-that-first-kiss/
Here’s one for ya!
http://www.bobpusateri.com/archive/2010/06/transactions-taking-the-plunge/
[…] , SQLServerPedia Syndication with 3 comments A few days ago Tim Ford (blog | twitter) put forth a challenge to describe a transaction in a non-technical fashion. I could have replied to the post directly, […]