In keeping with my last post, this is another ‘back to basic’s kind of thing. It’s basically a small metaphor of why we should use constraints, datatypes and other normal database design fundamentals when storing data and is aimed either at the complete newbie to database design or as a handy explanation to your Excel loving business users for more experienced developers…
There was a man who was very much in love with his fiancee. He wanted the very best for her for all things.
She loved gardening and working outside at the weekends but her tools and compost and plant pots were scattered around their garage. In order to make her life easier and happier, he built her a shed.
It was a fine shed for all her gardening things with hooks and shelves for her to put her things on. He roofed it watertight, painted the door her favourite colour and put a sign on it with her name – so that she would know that it was hers. She saw the shed and thought it was wonderful, and vowed to store all her gardening things there and be very content.
The first weekend she carefully placed her pots on one shelf, her compost bags in one corner, her tools in one rack and her gardening clothes on the hooks. She gardened and was delighted to have somewhere to put everything when she finished. She returned to the house aglow with appreciation.
The next weekend she gardened again, but it began to rain and she had to rush back to the house. She threw her things into the shed, making a promise to herself to put everything back in it’s place the next day. Unfortunately, the next day it rained too – so she stayed inside the house.
The third weekend the weather was glorious so she went to her shed to get her tools and pots and composts but she couldn’t find the ones she needed! She wasted half her day finding them and rearranging the shed. She returned to the house annoyed and frustrated.
The man saw her frustration and it pained him. He had built the finest of sheds but still it made her unhappy. He resolved himself to find a solution so that she would not feel this way again.
To this end, he hired a sorcerer. He explained his partner’s plight and the sorcerer said that the solution was simple. He would cast a number of spells on the shed so that she could never lose anything again.
He put a spell on the door so that only the lady could enter.
He put a spell on the whole shed so that only gardening things may be stored there.
He put a spell on the shelves so that only pots may go on one, only hand tools on another.
He put a spell on the hooks so that only clothes may hang there.
The fourth weekend was much like the second, with rain interrupting her work in the garden. As she rushed to the shed to throw her things in, she remembered the spells that had been cast. She spent an extra minute or so being careful to replace everything where it should be under the watertight roof, every time that she went to put something in the wrong place – it bounced back into her hand. She returned to the house. She knew that the shed could never be in disarray again and she was happy. The man saw that she was happy and so he felt happy too.
He resolved to sort out the garage next…
The shed is your database. The spells are your datatypes and constraints and security. Without them, no matter how careful you are, you will lose things and the shed will become a mess.
Look after your shed.