Why SQL Is So Often Learned the Wrong Way

Lesson 0001 — Why SQL Exists — ~12 min read

SQL is not a formula sheet. Most people start with SELECT, WHERE, JOIN and memorize syntax. The real question is why SQL exists at all — and what problem it solves that nothing before it solved reliably.

The Wrong Starting Point

Most learners begin SQL with commands. They see SELECT, WHERE, JOIN and immediately jump into writing queries. The learning becomes mechanical: write this, get that output, move on.

But SQL was never designed to be learned like a formula sheet. The real problem is not that SQL is difficult. The problem is that learners are rarely told why SQL exists in the first place.

Why SQL Exists — A Real Scenario

Imagine you are running a coaching institute. Very quickly, you realize you are no longer just teaching. You are managing data. You need to store:

At first, this feels manageable. You start with a notebook. Then you move to Excel and initially, it works.

But the real question is not “Can I store this data?”

The real question is “What happens when this grows?”

Data always grows.

Why Excel Eventually Breaks

Excel is not bad software. It is simply not designed for what databases are designed for.

# Failure Mode What Happens
1 Does not scale Excel struggles with large data. Real systems have multiple datasets, millions of records, and relationships between them. Think Swiggy or Uber — no realistic way to manage that volume in Excel.
2 Unsafe concurrency Excel allows multiple users to open a file but does not guarantee safe coordination. Two people editing the same cell can corrupt data. No strict locking like databases. In real systems, concurrency is not optional.
3 Cannot enforce strong rules Businesses survive on rules: fees > 0, email unique, attendance in valid format. Excel cannot enforce these reliably. Manual checks collapse at scale.
4 Complex questions become painful Simple: “How much fees did we collect this month?” is easy. Real: “Which batch has the lowest attendance trend?” / “Students with >80% attendance but paid late?” — Excel is not built for this at scale.
5 Weak security, audit, reliability Databases offer fine-grained access control, audit trails, safe crash recovery. Excel assumes things go right. Databases assume things will go wrong — and prepare for it.

This is the moment SQL becomes necessary.

Why does the coaching institute outgrow Excel?

What SQL Really Is

SQL stands for Structured Query Language. It is the language used to communicate with databases. But SQL is different from most languages beginners know.

Style You Tell The Computer… Example
Imperative (Java, Python) How to do it step by step — loop, check, compare, move forward for each row: if fees > 0: count++
Declarative (SQL) What you want — the database figures out how SELECT COUNT(*) FROM fees WHERE amount > 0

In SQL you say: “This is what I want.” You don't write loops. You don't explain how to search. The database engine figures that out internally.

Common beginner mistake: trying to think of SQL like Java or Python. Correct SQL thinking is about clearly describing the result, not the process.

SEQUEL vs SQL

SEQUEL was the earlier name during development (Structured English Query Language). SQL (Structured Query Language) is the official standard name. People still say “sequel” in speech, but in writing it's SQL.

What makes SQL declarative?

What a Database Actually Is

A database is simply an organized collection of data.

A practical mental model:

What if your laptop shuts down? Databases store data persistently on disk or SSD. If a crash happens mid-operation: the database checks its logs, incomplete operations are rolled back, completed operations are preserved. This is not luck — it is deliberate design.

How Databases Store and Access Data Internally

Databases do not store everything as one big file. Internally:

To search efficiently, databases use:

You don't need to master these internals immediately. But understanding them explains why SQL behaves the way it does.

Tables, Rows, and Columns

1. Table

A table is a structured collection of related data stored in rows and columns. Think of one sheet in Excel. Each table represents one kind of real-world thing.

customer_id name email signup_date is_active
1 Aisha Khan aisha@example.com 2024-01-10 1
2 Raj Patel raj.patel@sample.org 2024-02-15 0
3 Meera Joshi meera.j@example.com 2024-03-01 1

Example: customers stores people, orders stores purchases — each table one entity type.

2. Row / Record

A row (also called a record) is one complete entry — one horizontal line.

id name email city
1 Rahul Mehta rahul.mehta@mail.com Mumbai

3. Column / Field

A column (also called a field) is one attribute — one vertical heading. In the customers table above, name stores names, email stores emails. Each column has a type and a heading.

Relational vs NoSQL Databases

Aspect Relational NoSQL
Storage Tables (rows + columns), linked via relationships JSON documents, key-value pairs, graph structures
Example from coaching institute Student, Attendance, Fees tables joined via email One document per student bundling attendance + fees together
Examples MySQL, PostgreSQL, Oracle MongoDB, DynamoDB, Neo4j
Prioritizes Structure and correctness Speed and flexibility

Neither is “better.” They solve different problems.

Understanding Workloads: OLTP vs OLAP

A workload is the pattern of how a database is used — who queries, what queries, how often, how fast answers are needed.

Aspect OLTP (Online Transaction Processing) OLAP (Online Analytical Processing)
Purpose Day-to-day operations Analysis and decision-making
Users Many concurrent users Fewer users (analysts, leadership)
Queries Small, frequent, fast Large, complex, scanning huge data
Examples Paying fees, marking attendance, booking a cab, placing an Amazon order “Enrollments per year for 5 years?” / “City with most users?”
Optimized for Speed + accuracy + consistency Patterns and trends over history

Knowing this explains why some systems are tuned for speed and others for analysis.

Transactional Databases

A transaction is a group of operations that must succeed together. Not a single query — a bundle that logically belongs together and must behave as one unit.

Rule: either everything succeeds, or nothing is allowed to change. No “half done” state.

What a Transaction Looks Like

Student pays fees online. Internally:

  1. Deduct money from the student's wallet
  2. Record the payment in the finance table
  3. Update the student's status as “Fees Paid”

To the user it's one action: “Pay Fees”. Imagine money is deducted but the payment record is not saved and status not updated — disaster. Student loses money but system says “Not Paid”.

This is the all-or-nothing rule.

How Databases Enforce It

Mechanism How It Works
1. Transaction Log (Write-Ahead Logging) Before touching real data, write “I am about to change X to Y” to a log on disk. On crash, restart reads the log: unfinished transactions are rolled back, committed ones reapplied. Money doesn't vanish.
2. Isolation: Locks or MVCC Others must not see half data. Via locks (block touching same data) or MVCC (keep multiple row versions). Everyone sees old or fully-committed data — no messy middle.
3. Commit Only When Safe Marked successful only when all ops ran, log is safely written, data is consistent. Otherwise ROLLBACK — throw away changes. Only then COMMIT.

ACID Properties

When people trust a database with money, marks, or medical data, they trust one idea: the database will never leave data in a broken state. That trust comes from ACID.

Property Guarantee Example
A — Atomicity
(All or Nothing)
Transaction = one unit. 10 steps → all 10 or none. No 50% done. Fee payment: deduct + record + status. If step 2 fails, step 1 is undone, step 3 never runs. No “money gone but not paid”.
C — Consistency
(Rules Never Broken)
After every COMMIT, all rules hold: primary keys, foreign keys, balance ≥ 0, marks 0–100. Transaction trying to set balance to -500 is rejected / rolled back.
I — Isolation
(Users Don't Interfere)
Concurrent transactions behave as if alone. Via locks or MVCC. Two users booking the last seat: one succeeds, one fails — never both.
D — Durability
(Committed = Permanent)
Once COMMIT, data survives power loss / crash / restart via logs + disk writes. “Payment Successful” survives a server crash one second later.

Two students click “Book” on the last seat at the same time. What does Isolation guarantee?

DBMS and RDBMS

A common misunderstanding is to think a database is just “data on disk”. Data alone is useless. What makes it powerful is the software layer that controls storage, access, protection, and recovery.

That software is called a DBMS.

Term What It Is Scope
DBMS
(Database Management System)
The engine between applications and raw data on disk. Decides how data is stored, who can access it, how crashes recover, how concurrency is managed. General concept — without it you'd manually read/write files and any crash destroys consistency.
RDBMS
(Relational DBMS)
A DBMS for relational data: tables with fixed schemas, primary/foreign keys, joins, SQL, strong ACID guarantees. Special type of DBMS. All RDBMS are DBMS. Not all DBMS are relational.

A DBMS doesn't just store — it actively manages. An RDBMS is the relational flavor that enforces tables, keys, joins, and SQL.

Notes

Why SQL exists :-

Data always grows → Excel breaks on 5 axes

a) Scale — millions, many tables, relationships (Swiggy/Uber impossible in Excel)

b) Concurrency — two edits same cell → corruption; DB has locks/MVCC

c) Rules — fees > 0, email unique, format valid — Excel can't enforce reliably

d) Complex Qs — “late payers last 6 months + >80% attendance” painful in Excel

e) Recovery/Security — audit, access control, crash rollback in DB; Excel assumes happy path

SQL mental model :-

SQL = Structured Query Language (SEQUEL was historic name)

Declarative: say what you want, not how — engine plans execution

Imperative (Java/Python): step-by-step how; SQL: describe result

Beginner trap: thinking in loops; correct: think in result sets

Database internals :-

DB = folder → tables (rows × columns) → persistent on disk/SSD

Rows in pages → blocks disk↔memory → buffer cache in RAM

Indexing: B+/B-trees, hash, cache explains why SQL needs planning

Table = one entity type; Row = one record; Column = one attribute

Relational vs NoSQL / OLTP vs OLAP :-

Relational: tables + relations via keys (MySQL/Postgres) → structure/correctness

NoSQL: docs/key-value/graph (MongoDB) → speed/flexibility, co-located data

OLTP: many users, tiny frequent queries, fast/consistent (pay fees, book cab)

OLAP: analysts, huge scans, trends (enrollments per year, city with most users)

Transactions & ACID :-

Transaction = bundle that is all-or-nothing (deduct → record → status)

Enforced via: 1) WAL (log before data, rollback/reapply on crash) 2) Locks/MVCC 3) COMMIT only when safe else ROLLBACK

A: Atomicity — all steps or none; C: Consistency — rules never broken; I: Isolation — concurrent == alone (one seat winner); D: Durability — committed survives crash

DBMS = engine managing storage/access/crash/concurrency; RDBMS = relational DBMS with SQL + ACID + keys/joins

Primary sources: Silberschatz — Database System Concepts (Ch. 1) · Postgres SELECT docs. Ask me anything that's unclear.

Next: Database & Table Basics →

Questions? Ask your agent — you can follow up on any concept, quiz answer, or how this applies to a specific query. Review the SQL glossary or syntax quick reference for a compressed overview.