| Lesson 2 | What is SQL? |
| Objective | Understand what SQL is and how it was conceived. |
Structured Query Language (SQL) is the standard language for working with data in relational databases. Instead of writing step-by-step programs, you describe the data you want, and the database engine figures out how best to return it.
In other words, SQL is a declarative, set-based language designed so that:
SQL did not appear by accident. It grew out of early research at IBM into how data could be stored and queried using a mathematical foundation called the relational model, proposed by Edgar F. Codd in 1970.
Key milestones in SQL’s origin story:
Today, SQL is everywhere: powering transactional systems, analytics platforms, reporting tools, data warehouses, and many cloud-native services.
SQL is not a general-purpose programming language. Instead, it focuses on a few core tasks that every relational database must support:
CREATE TABLE, ALTER TABLE, DROP TABLECREATE VIEW, CREATE INDEX, and related statementsSELECT – Query dataINSERT, UPDATE, DELETE – Modify dataGRANT, REVOKE – Control accessCOMMIT, ROLLBACK – Manage transactionsA simple SQL query might look like this:
SELECT first_name,
last_name,
salary
FROM Employees
WHERE salary > 50000;
You describe the result set (columns and conditions), and the database decides whether to use an index, how to join tables, and which physical operations to apply.
SQL is deeply influenced by relational algebra, which defines a small set of mathematical operations on tables (relations).
Core relational algebra ideas reflected in SQL:
WHERE clauseSELECTJOIN formsUNION, INTERSECT, EXCEPT/MINUSFor teaching, relational algebra is valuable because each operation is written as its own step, making the underlying logic explicit. SQL combines many of these ideas into a single statement, making it more practical for day-to-day use but slightly less “pure” from a theoretical perspective.
Modern SQL follows the spirit of the relational model while also including pragmatic extensions (window functions, common table expressions, JSON support, procedural logic, etc.) driven by real-world needs.
SQL is often described as declarative because you specify the desired result, not the algorithm used to compute that result.
Consider this example:
SELECT name
FROM Employees
WHERE department = 'Sales';
You do not tell the database:
Instead, the query optimizer inside the RDBMS chooses a plan based on statistics, indexes, and available paths. That separation of what (your query) from how (the execution plan) is the hallmark of declarative SQL.
Another example of a set-based, declarative operation:
UPDATE Orders
SET status = 'Processed'
WHERE status = 'Pending';
This statement tells the database which rows should change and how they should change, but not whether it should use an index, a full scan, or a particular loop structure.
Many databases also offer procedural extensions (PL/SQL, T-SQL, PL/pgSQL) that let you write loops and control flow. Those extensions are imperative, but the core SQL query language remains declarative.
Although SQL was conceived in the 1970s, it remains central to modern data platforms:
Understanding how SQL was conceived—as a relational, set-based, declarative language—helps you:
In the next lesson, you will begin working with concrete SQL examples to see these concepts in action.