What Is SQL? The Language of Data Explained
A clear, no-hype introduction to SQL — what relational databases are, why declarative querying matters, the main dialects, and when SQL beats spreadsheets or NoSQL.
What you'll learn
- ✓What a relational database actually is, in concrete terms
- ✓Why SQL is declarative — and why that matters
- ✓How the main dialects (Postgres, MySQL, SQLite) relate to each other
- ✓When SQL is the right tool, and when a spreadsheet or NoSQL store fits better
- ✓How to read your first SELECT query without panicking
Prerequisites
- •Comfort using a terminal or a text editor
- •No prior database experience required
SQL is the language almost every serious software system uses to store and retrieve data. Banks, hospitals, airlines, social networks, e-commerce sites, and your favourite mobile app almost certainly speak SQL somewhere behind the scenes. It has been around since the 1970s and shows no sign of slowing down.
This post explains what SQL is, what a relational database actually means, and when SQL is the right hammer for the nail in front of you.
The problem SQL solves
Before relational databases, application data lived in custom file formats or hierarchical stores. Asking simple questions — “how many customers in France bought more than once last month?” — required writing custom traversal code for each new question. Reports were slow, brittle, and rewritten constantly.
In 1970, Edgar F. Codd, a researcher at IBM, proposed organising data into relations — what we now call tables — with a mathematical foundation that let any question be expressed as a transformation over those tables. SQL (Structured Query Language) became the practical language built on that model in the late 1970s.
The key insight: instead of writing how to fetch data step by step, you describe what you want, and the database figures out the most efficient way to get it.
What a relational database actually is
A relational database is a collection of tables. A table is a grid:
- Columns define the shape — names, types, and constraints (for example,
email TEXT NOT NULL UNIQUE). - Rows are individual records that match that shape.
Here is a tiny users table:
| id | name | country | |
|---|---|---|---|
| 1 | Ada | ada@example.com | UK |
| 2 | Linus | linus@example.com | FI |
| 3 | Grace | grace@example.com | US |
Tables relate to each other through shared columns. An orders table might have a user_id column referencing users.id. That is the “relational” part — the database understands those references and can join the two tables for you when you ask a question that spans both.
This sounds modest, but it is the foundation of almost every business application written in the last forty years.
SQL is declarative
Most programming languages — Python, JavaScript, C — are imperative. You write a sequence of steps and the machine follows them. SQL is declarative: you write what the result should look like and the database engine plans the steps.
Compare a question in English with the SQL that expresses it:
“Give me the names and emails of users from France, sorted alphabetically.”
SELECT name, email
FROM users
WHERE country = 'FR'
ORDER BY name;
That is essentially the entire mental model. Notice what is missing: there is no loop, no index lookup, no instruction about how to scan the table. The database’s query planner chooses an execution strategy based on the table size, the indexes available, and the statistics it has collected. Two databases with the same data will often pick different plans, and a query you write today may run faster next year as the planner improves.
This is also why SQL ages so well. The query you wrote in 2005 still runs — and probably runs faster — on the same database in 2026.
The dialects: Postgres, MySQL, SQLite, and friends
SQL is standardised (ANSI SQL, ISO SQL), but every database vendor extends the standard with its own features. In practice, the three dialects you will encounter most often as a beginner are:
PostgreSQL. The most fully featured open-source database. Excellent standards compliance, rich type system (JSON, arrays, geospatial), and a strong reputation for correctness. The default choice for most new projects that need a real database.
MySQL (and its fork MariaDB). Historically the database behind WordPress, much of Web 2.0, and many shared-hosting providers. Slightly looser defaults than Postgres, but extremely well known and reliable.
SQLite. A single-file embedded database with no server process. The most-deployed database engine in the world — it ships inside every iPhone, every Android device, every browser, and most desktop applications. Perfect for learning SQL and for small to medium applications.
There are also SQL Server (Microsoft), Oracle Database, and cloud-native engines like BigQuery and Snowflake. They all speak SQL with their own flavour.
The good news: about 90% of the SQL you write — SELECT, WHERE, JOIN, GROUP BY — is identical across all of them. Once you learn one dialect, switching to another is a matter of looking up the edge cases.
When SQL beats a spreadsheet
Spreadsheets are wonderful for small, ad-hoc analysis. They start to crack when:
- The data grows beyond a few hundred thousand rows
- More than one person needs to edit it at the same time without overwriting each other
- You need referential integrity (“this order must belong to a real customer”)
- You need to run the same analysis on different slices of data repeatedly
- You need to embed the data in an application that other software can query
At that point, a relational database with SQL is the right tool. You get:
- Concurrency. Many clients can read and write safely at once.
- Transactions. A group of changes either all happen or none of them do.
- Constraints. The database enforces rules so bad data never lands in the first place.
- Performance. With the right indexes, queries against millions of rows return in milliseconds.
When SQL is not the right tool
Be honest about the tradeoffs. SQL and relational databases are not always the answer:
- Document-shaped, schema-loose data — for example, raw event logs with wildly varying shapes — is sometimes easier in a document store like MongoDB.
- Massive horizontal scale with simple key/value access (think: shopping cart sessions for a billion users) is often handled by stores like DynamoDB or Redis.
- Full-text search over articles or product descriptions is better served by Elasticsearch, Meilisearch, or Postgres’s own full-text features paired with a search-specific index.
- Graph-heavy traversal (“friends of friends of friends”) can be more natural in a graph database like Neo4j.
That said, most teams reach for “NoSQL” too early. A modern Postgres handles JSON columns, arrays, full-text search, and tens of thousands of writes per second on a single modest server. Start with SQL; switch only when you have a concrete reason.
A first concrete example
You do not need anything installed to read this. Here is a minimal users table with three rows and the SQL to query it.
-- Create the table
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE,
country TEXT
);
-- Insert some rows
INSERT INTO users (id, name, email, country) VALUES
(1, 'Ada', 'ada@example.com', 'UK'),
(2, 'Linus', 'linus@example.com', 'FI'),
(3, 'Grace', 'grace@example.com', 'US');
-- Ask a question
SELECT name, email
FROM users
WHERE country = 'UK';
The result of the last query is one row:
name | email
-----+------------------
Ada | ada@example.com
That is SQL. The syntax you just read is, in essence, what runs inside every bank, airline, and government database in the world — at a much larger scale.
Try it yourself. If you have a browser, open sqlite.org/fiddle and paste the three statements above. Run them, then change 'UK' to 'US' and run the SELECT again. You have just done what every data analyst, backend engineer, and BI report does dozens of times a day.
How SQL fits with the rest of the stack
SQL rarely lives on its own. In a typical web application:
- A backend service written in Python, JavaScript (often on Node.js), Go, or Java connects to the database.
- The backend builds SQL queries — usually through a library or ORM — and sends them over the network.
- The database returns rows; the backend turns them into JSON for a React frontend or another consumer.
You do not write SQL inside the browser. You write it inside the part of your application that runs on a trusted server.
What SQL is not
SQL is not a programming language in the everyday sense. You don’t build full apps in SQL. You use it to ask questions of data and to change data.
SQL is not the same as a specific database product. “I know MySQL” and “I know SQL” overlap but are not identical.
“NoSQL” does not mean “no SQL allowed.” Many modern NoSQL systems have bolted on SQL-like query languages because the demand is universal.
Recap
You now know:
- A relational database is a set of tables, with rows and typed columns, related to one another by shared keys
- SQL is a declarative language: you describe the result you want and the engine plans how to fetch it
- The main dialects — Postgres, MySQL, SQLite — share a large common core
- SQL is the right tool when you need concurrency, transactions, constraints, and consistent performance over structured data
- It is not always the right tool — but reach for it first; switch only when you have a real reason
Next steps
The next post is hands-on: writing real SELECT queries against a small users and orders dataset. By the end of it, you will be able to filter, sort, and slice data with confidence.
→ Next: SQL SELECT — Your First Queries
Questions or feedback? Email codeloomdevv@gmail.com.