DBS:- SQL as a declarative language

There are two types of programming Language paradigm

1. Imperative Language

An imperative language tells the computer to perform certain operations in a certain order. For example Lets assume that we have CSV file of data about College. In order to find all the students from “Computer Science” department we will write program as follow.

We can see ourselves stepping through the code line by line, evaluating conditions, updating variables, and deciding whether to go around the loop one more time.

Most of the programming languages today are imperative.

2. Declarative query language

In a declarative query language, We just specify the what data we want, but how to achieve that we delegate it to the language engine.

For example in SQL, the above program can be written something like.

This is pretty cool and de-facto standard in Database query languages. We delegate the implementation details to the Query Engine this makes it easier to introduce performance improvement without requiring any changes to the queries.

This blog is part of the blog series Developer’s bedtime stories. Please check my other articles with a prefix to the article name as DBS, short for Developer’s Bedtime Stories.

A wizard with no Magic.