1.1 What Databases and SQL Are
A database stores, queries, and maintains data over time. A relational database organizes data into tables: columns define meaning, and rows store concrete records.
SQL stands for Structured Query Language. It is not a private language owned by one database product. It is a general language family for working with relational databases.
Common database products
You will often hear these names:
- MySQL / MariaDB: common in web applications.
- PostgreSQL: strong standards support, type system, and extension ecosystem.
- SQLite: lightweight, often used for local files, mobile apps, and small tools.
- SQL Server: common in Microsoft ecosystems.
- Oracle Database: common in large enterprise systems.
They all support SQL, but not every detail is identical. Learn the transferable concepts first, then check product documentation in real projects.
Major SQL categories
| Category | Common statements | Purpose |
|---|---|---|
| DDL | CREATE, ALTER, DROP | Define and change structure |
| DML | INSERT, UPDATE, DELETE | Change rows in tables |
| Query | SELECT | Read data |
| Transaction | BEGIN, COMMIT, ROLLBACK | Commit or undo a group of changes |
| Security | GRANT, REVOKE | Control permissions, with many product differences |
You can think of SQL actions in two broad groups: changing structure, and reading or changing data.
A query is not a manual loop
SELECT name, score
FROM students
WHERE score > 85
ORDER BY score DESC;This statement does not tell the database "open row 1, then row 2". It describes what you want: take name and score from students, keep rows with score above 85, and sort by score descending.
The database decides how to execute it. It might scan the table, use an index, filter first, or join first. That decision process is optimization.
Standard SQL and product dialects
This course uses general SQL whenever possible. When syntax is clearly product-specific, it will be marked directly beside the example.
A good SQL learning order
Do not begin by memorizing every function. A better route is:
- Tables and columns: where data lives.
- Primary and foreign keys: how rows connect reliably.
- SELECT: how to read data.
- WHERE and ORDER BY: how to filter and sort.
- JOIN and GROUP BY: how to combine and summarize.
- Transactions, locks, and indexes: how to run safely and efficiently.