When I’m not working on data, or blogging about data or thinking about data, I go to ballet class. It makes my brain work in different ways, it’s very challenging and who doesn’t want to dance like a ballerina?
This week I had obviously not really switched off from work, as I got to thinking: a ballet class is a good way to describe database concepts.
Let me explain.
If you’ve never been to a ballet class it generally begins with a warm-up at the barre.
Our teacher is the PRIMARY KEY. She is UNIQUE, identifies all ‘rows’ in the class and is not NULL. She maintains our entity integrity. The teacher from the Jazz class usually visits and she is our FOREIGN KEY. She maintains our referential integrity.
Everyone lines up in order at the barre. This is the same order every time, as everyone likes their own spot. This is our clustered index.
We then begin our exercises at the barre. We move through 1st, 2nd and 3rd position. Once we get to 3rd position we are considered warmed up and ready for more challenging exercises. The same way once we reach 3rd Normal Form, our data is considered ‘Normalised’.
These exercises, just like moving through the forms of data normalisation, build on each other, are based on formal rules and are the basis of the art form.
After barre, everyone moves into the centre. We work in a group where everyone works through exercises and turns together. When we perform solo, DISTINCT, we come out one at a time to perform.
When we begin to practice our combinations with a partner from the class next door, there is an INNER JOIN and everyone has someone to dance with.
The last part of the class is the rehearsal for the next show. We BEGIN TRANSACTION to start, and work through our ideas around the music and what looks good.
If we are happy with what we’ve come up with then we COMMIT and if not we ROLLBACK.
At the very end of class, we curtsy and then TRUNCATE (not DELETE). We will be back next time to INSERT, UPDATE and SELECT again, with all our jargon.
Photo by Beto Franklin on Pexels
This post first appeared on dev.to