FOUNDATION
BEGINNER
lesson-01
Introduction to SQL & Databases
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.
Section 1
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
Section 2
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
RelationalPostgreSQL
Most advanced features, highly standards-compliant
RelationalSQLite
Embedded, zero config — great for local apps
EmbeddedSQL Server
Microsoft enterprise-grade database platform
EnterpriseOracle DB
Enterprise legacy powerhouse used in large corps
EnterpriseMariaDB
MySQL fork with additional performance improvements
RelationalSection 3
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
Section 4
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"
Section 5
SQL Sublanguages
SQL is divided into four sublanguages, each serving a different purpose.
DML
Data Manipulation Language — SELECT, INSERT, UPDATE, DELETE
Most CommonDDL
Data Definition Language — CREATE, ALTER, DROP, TRUNCATE
SchemaDCL
Data Control Language — GRANT, REVOKE permissions
SecurityTCL
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.