Thursday, June 21, 2012

SQL - the database champion

SQL - stands for Structured Query Language, is a programming language to handle DataBase Management Systems (DBMS). The above sentence might ring a bell in many of the geeky minds, but may not be perceived in the same way by a non-geek. Let me handle this definition in a more simplistic manner.

Let’s imagine a small 10-page book with minimal words and a few pictures (more like a comic book most of us read in our childhood). If we are given a task to find a particular unique word within those 10 pages, it might take us not more than 10 minutes (much lesser if it’s an interesting comic book that we have read repeatedly). Now let’s increase the difficulty level a bit. If we are given a 100-page book and asked to again find a specific unique word within those 100 pages, it might take us a couple of hours (if the book is one of our academic books, then it might take a few days as well). And finally, if we are given access to a library that contains more than a 100 books and we are now asked to find a single unique word among them - that can be a month-long arduous assignment. This is where database management technology comes into the picture.


Database means a collection of data, not necessarily pertaining to just books or computers, but any tangible or intangible data that can be stored and accessed. Managing this database needs a process and certain rules. These rules are devised using a common database programming language. Why need a common language you ask? We all use dictionaries and any kind of English dictionary always has words aligned alphabetically. This arrangement of words is followed by all the English dictionaries, irrespective of the publisher and the author. This common arrangement helps us sift through the words easily to search for the word we are looking for. Now imagine if every publisher has its own way of arranging these words – a few arrange them in the reverse alphabetical order, some others arrange them according to the relevance of the alphabets, and so on. This would make the process of reading these dictionaries very complicated as we would have to get used to the individual processes of the dictionaries. Hence, a common programming language is required to handle a database of any kind.

We all know, data in today’s world is not restricted to a few pages, or a 100 books or even a group of libraries. Today we are looking at data that runs into sizes or pages we cannot imagine. You can experience a small example of the amount of data that goes on the internet in today’s day by visiting one of the most visited site today – Google. Type an English word that we use in our daily language and press Enter. Just below the search bar you will find text similar to – About 21,000,000 results in 0.3 seconds. And the most astonishing fact is, these 21,000,000 results are not words or alphabets. These are links to websites that have tons of data on each of them. And all of them can be searched in a fraction of a second. That is just a miniscule example of how advanced our technology has grown.

Now coming back to where we started, SQL is a database management programming language. You might ask how a computer can find such huge amounts of data in a fraction of a second. The answer lies in the SQL (and many other much advanced) programming language. As we all communicate with each other, we can communicate with the computer using languages like SQL. SQL contains various commands or words that have a specific meaning and it has rules that are understood by the computer. For example:

The easiest to comprehend SQL command would be –

SELECT * FROM Books WHERE price>50;

When we type this command and try to execute it, the computer searches for all the books that the database contains and searches for their prices. It selects all the books that have a price greater than 50 and displays all the information about them on the screen in a tabular format. (the * in the code specifies that we need all the information about the books. If we type SELECT Name FROM…..  the result will be only a list of book names that have a price greater than 50)

As you must have noticed I have written a few words in capitals (SELECT, FROM, WHERE). The capitals do not have a specific meaning and are understood by the computer irrespective of them being in capitals (though a few programming languages are case-sensitive). But it’s for our own ease to use the upper case as it is more convenient and makes the code understandable.

On similar lines, using the programming language we can search for a particular data within data of an unimaginable size. We can also Create, Edit, Delete, Update and play around with the data as we want. We can create indexes as we have at the start of our books, we can sort data, and use the database for purposes that seem impossible otherwise.

Disclaimers:
If you get a deja vu feeling while reading this post and you feel you have read it somewhere before, please don't rack your brains too much; i had volunteered to write a post on technology for my friends' blog : http://galacticnetone.wordpress.com/2012/06/20/basic-introduction-to-sql/

The intention of this blog post is not to make you an expert in SQL or even to take you for a short tour through the programming language. The motive is to give a basic introduction to what a database management programming language is, and why do we require it. If you wish to learn more about SQL as a programming language follow this blog or visit http://en.wikipedia.org/wiki/SQL.



No comments:

Post a Comment