FOUNDATION BEGINNER lesson-01

Introduction to SQL & Databases

🕑 25 min
📃 5 sections
🎓 Foundation
SQL is the universal language for working with databases. Every app you use stores data in a database, and SQL is how that data gets retrieved, updated, and analyzed. This lesson covers what databases are, how relational databases work, and why SQL is the most in-demand data skill in the world.

What is a Database?

A database is an organized collection of structured data stored electronically. Unlike a spreadsheet, a database can store millions of rows efficiently and let multiple users query it simultaneously.

Key terms: Table (like a spreadsheet tab), Row (one record), Column (one attribute), Primary Key (unique ID for every row)

80%
of Fortune 500 use SQL databases
50+
years — SQL created in 1974
#1
Most in-demand data skill
$120K+
Avg SQL Developer salary

Relational vs NoSQL

Relational: structured tables, ACID transactions, SQL language — MySQL, PostgreSQL, SQLite, SQL Server

NoSQL: flexible documents, horizontal scale — MongoDB, Redis, Cassandra, DynamoDB

ℹ️
When to Use Each
Use relational DBs when your data is structured and relationships matter. Use NoSQL when you need flexible schemas or massive horizontal scale.
🌡️
MySQL
Most popular open source relational database
Relational
🚀
PostgreSQL
Most advanced features, highly standards-compliant
Relational
📂
SQLite
Embedded, zero config — great for local apps
Embedded
🏢
SQL Server
Microsoft enterprise-grade database platform
Enterprise
💾
Oracle DB
Enterprise legacy powerhouse used in large corps
Enterprise
🐠
MariaDB
MySQL fork with additional performance improvements
Relational

SQL Execution Order

SQL clauses execute in a different order than how you write them. Understanding this prevents confusing errors.

Internal SQL Execution Order
FROM
→
JOIN
→
WHERE
→
GROUP BY
→
HAVING
→
SELECT
→
ORDER BY
→
LIMIT

Your First SQL Statement

SQL
-- The most basic SQL query
SELECT * FROM students;

-- Read it as: "Get all columns FROM the students table"
-- SELECT = what columns to return (* = all)
-- FROM = which table to look in

-- More specific:
SELECT name, age FROM students WHERE grade = 'A';
-- "Get name and age FROM students WHERE grade equals A"

SQL Sublanguages

SQL is divided into four sublanguages, each serving a different purpose.

📄
DML
Data Manipulation Language — SELECT, INSERT, UPDATE, DELETE
Most Common
🏗️
DDL
Data Definition Language — CREATE, ALTER, DROP, TRUNCATE
Schema
🔒
DCL
Data Control Language — GRANT, REVOKE permissions
Security
🔁
TCL
Transaction Control — COMMIT, ROLLBACK, SAVEPOINT
Safety
🎤 Knowledge Check
1. What does SQL stand for?
Correct! SQL = Structured Query Language — the standard language for relational databases since 1974.
2. What is a PRIMARY KEY?
A PRIMARY KEY uniquely identifies every row in a table. No two rows can share the same primary key value, and it cannot be NULL.
3. Which is a relational database?
MySQL is a relational database. MongoDB, Redis, and Cassandra are all NoSQL databases.
4. In SQL execution order, which clause runs FIRST?
FROM runs first — the database must identify the source table before it can do anything else. SELECT actually runs near the end!
5. Which SQL sublanguage does SELECT belong to?
SELECT is DML — Data Manipulation Language. DML covers SELECT, INSERT, UPDATE, and DELETE.
Finished this lesson?
Mark it complete to track your progress.
🗒 Cheat Sheet 📝 Worksheet