SQL
Structured Query Language — the standard language for querying relational databases. SELECT, INSERT, UPDATE, DELETE, JOIN, and WHERE let you read and modify data in tables. SQL is 50 years old and still the most common way to query data. Every developer should know basics.
- Querying relational databases.
- Any app using PostgreSQL/MySQL/SQLite/SQL Server.
- Non-relational data (use NoSQL).
- Full-text search at scale (use Elasticsearch).
Definition
SQL is a declarative language for relational databases. You describe what data you want (SELECT), not how to get it. The database optimizes the query plan. Core: SELECT (read), INSERT (add), UPDATE (change), DELETE (remove), JOIN (combine tables), WHERE (filter), GROUP BY (aggregate).
Why it exists
To provide a standard, declarative way to query relational data so applications and tools work across database vendors (PostgreSQL, MySQL, SQLite, SQL Server).
How it works
Write SQL statements. The database parses, optimizes (query planner), and executes them. SELECT returns rows; INSERT/UPDATE/DELETE modify. JOINs combine tables on keys. Indexes speed up WHERE/JOIN. Transactions group statements atomically.
Scaling limits
Complex queries can be slow without indexes. SQL dialects vary between databases. No native support for graphs/documents (use NoSQL). Injection attacks if not parameterized.
Cost shape
Free — SQL is a standard.
Alternatives
- NoSQL query APIs — Flexible schemas but less query power.
- ORM (write code, not SQL) — Easier but can generate slow queries.
Failure modes
- SQL injection (use parameterized queries!).
- N+1 queries from ORMs.
- Missing indexes causing slow queries.
- Dialect incompatibilities.