SQL

The standard language for managing and querying relational databases.

Declarative
Beginner
1974
Donald Chamberlin, Raymond Boyce (IBM)

Overview

SQL (Structured Query Language) is the standard language for relational database management systems. It is used for storing, manipulating, and retrieving data in databases like PostgreSQL, MySQL, SQLite, and Microsoft SQL Server.

Key Features

  • Declarative syntax — Describe the result, not the steps
  • ACID compliance — Transactions with atomicity, consistency, isolation, durability
  • Joins — Combine data across multiple tables relationally
  • Window functions — Advanced analytics (ranking, running totals)
  • Ubiquitous — Every major RDBMS supports SQL

Code Example

sql
SELECT
    department,
    employee_name,
    salary,
    RANK() OVER (PARTITION BY department ORDER BY salary DESC) as rank,
    AVG(salary) OVER (PARTITION BY department) as dept_avg
FROM employees
WHERE hire_date >= '2020-01-01'
ORDER BY department, rank;

Learning Resources

Learning Path

13 topics across 4 sections

1Basics

2Joins & Relationships

  • Joins — INNER, LEFT, RIGHT, FULL OUTER, CROSS, and self joins
  • Subqueries — Scalar, row, and table subqueries, correlated subqueries
  • Set Operations — UNION, INTERSECT, EXCEPT, and their ALL variants

3DDL & DML

4Advanced