If SQL seems a bit more different to you than C++, for example, this is because SQL is a declarative language. Understanding how SQL fits the whole picture will be much easier if you know what databases are all about. SQL is just the programming language you need to execute commands that let you create and manipulate a relational database.
Which Are the Different Types of Programming?
We will not delve into strict and detailed technical definitions to explain how it works. What you need to know is that there are a few types of programming out there – procedural (imperative), object-oriented, declarative, and functional.
Although it has some procedural elements, SQL is a declarative language - it is nonprocedural. This means, while coding, you will not be interested in how you want the job done. The focus is on what result you want to obtain.
A Procedural vs a Declarative Language
An abstract example would best clarify what the difference is between using a procedural and a declarative language.
The Way to Solve Tasks using C or Java
When using a procedural language, such as C or Java, we must explicitly divide the solution of a certain problem into several steps. For instance, if we wanted to tell the machine to bring us a bucket, in Java we would have to turn the following steps into code:
- Please, open the door.
- Go outside.
- Pick up the bucket I left there.
- Bring it back to me.
The Way to Solve Tasks Using SQL In a declarative language, the same task would sound like:
- Fetch the bucket, please.
And you wouldn’t have to go through the process step by step. The algorithms are built-in, and there is an optimizer, which will separate your task into smaller steps and do the magic to bring the desired output.
This is important because when using SQL, you should concentrate on what you want to retrieve from your database. Unless you are an advanced user, don’t bother with the algorithms explaining how your data can be obtained.
How to Work With SQL
To sum up, SQL and Java have nothing in common when it comes to the way you go about solving tasks. Now you know that you should be focused on what you want to do rather than how to do it. If you want to expand your knowledge even more, don’t think twice before diving into the concept of relational databases.
***
Eager to hone your SQL skills? Enroll in our SQL course.
Next Tutorial: Relational Databases