SQL is a Declarative Language

SQL Tutorials 5 min read
sql is a declarative language

SQL is a Declarative Language

5 min read
Blog / SQL Tutorials / SQL is a Declarative Language

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.

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.

Types of programming, procedural object oriented, declarative, 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.

SQl is declaritive

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:

  1. Please, open the door.

imperative process of getting a bucket

  1. Go outside.
  2. Pick up the bucket I left there.
  3. Bring it back to me.

data-science-training

The Way to Solve Tasks Using SQL

In a declarative language, the same task would sound like:

  1. 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.

4 items describing how to get the bucket and one on what the process is

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.

What is the most important part

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? Learn how to put theory into practice with our hands-on tutorials!

Next Tutorial: Relational Databases

Leave a Reply

Your email address will not be published.

A Free Data Science Career Guide?

Check your email shortly!