What is SQL?
SQL stands for Structured Query Language and is the tool which you can use to extract information from your database and display it in a customized way.
Just from the name of this programming language we can learn a few things about what is SQL. The fact that the programming language is
- STRUCTURED: data which is stored in the databases is structured in an organized in tables which can be interconnected.
- QUERY: this programming language is used to “ask” the database to return some data which it has stored.
Why would you use SQL?
SQL is specifically designed and is a standard language which works with Relational Databases.
What are relational databases?
A Relational Database is a collection of information stored into structures called tables and all is organized according to a relational model. Basically, relational means that information is logically connected to other pieces of information.
A person has to have a name, a phone has to have a phone number, a car has to have a color. All of these details, which belong to different real life objects can be stored in a relational database as linked information.
The most common Relational Database Management Systems (RDBMS) are:
- SQL Server (Microsoft SQL)
- IBM DB2
- SAP Sybase
Although, even if all of these database systems use SQL, each of them use a slightly different version (dialect) of SQL.
Oracle database systems uses PL/SQL (Procedural Language/Structured Query Language), SQL Server uses T-SQL also known as Transact-SQL.
The advantages of using SQL directly:
- It allows users to access their data from their databases and to describe their data
- Allows users to define or modify the data in their databases systems
- It offers direct access to manipulating the databases and/or the tables stored in the databases
- Allows users to directly create programatic functions which can run directly on the database, without the need of an external application
To get even a more complete overview of what is SQL it would be useful to know how it works. Everytime you send a command (in technical language this is called a query) to the database, for most of the database systems there is a process that happens:
- The SQL Query which you send to the database to extract information is first handled (read) by the Query Language Processor. This component decides if the query you wrote is syntactically correct (all of the commands are in the correct order and follow the STRUCTURE defined by that particular dialect of SQL).
- The job of the Query Language Processor is done in part by the Parser, which takes care of the syntax of the query
- If the syntax is correct, the Optimizer comes into action and determines the best way of executing the query based on current state of the database system
- The next step calls onto the DBMS Engine where all the actions of creating, reading, updating or deleting data from a database happen.
- This job is also made partly by the File Manager, which takes care of looking up and reading or altering data on the database’s physical disks.
- The Transaction Manager’s role is to make sure that all queries that execute on the database will follow the rules specified by ACID