Skip to content

SQL - Overview

Welcome to the world of SQL! This chapter provides an overview of what SQL is, why it remains critically important in today’s technology landscape, and how it functions as the language of data.

SQL, or Structured Query Language, is the standard programming language for managing and manipulating data held in a Relational Database Management System (RDBMS). It is a declarative language, meaning you describe what data you want, and the database engine figures out how to retrieve it efficiently.

Virtually all relational databases—such as MySQL, PostgreSQL, SQL Server, Oracle, and SQLite—use SQL as their core language. It allows you to perform a wide range of tasks, including:

  • Data Definition Language (DDL): Creating, modifying, and deleting database structures like tables and indexes (CREATE TABLE, ALTER TABLE).
  • Data Manipulation Language (DML): Inserting, updating, deleting, and retrieving data from tables (INSERT, UPDATE, DELETE, SELECT).
  • Data Control Language (DCL): Managing user permissions and access to data (GRANT, REVOKE).

While SQL is an ANSI/ISO standard, different databases have their own extensions or “dialects” (e.g., T-SQL for Microsoft SQL Server, PL/pgSQL for PostgreSQL). However, the core DDL and DML commands are largely portable across systems.

Decades after its creation, SQL remains a cornerstone of software development and data analysis for several key reasons:

  • Universal Standard: It’s the lingua franca for relational data. Knowing SQL opens up access to a vast ecosystem of powerful database technologies.
  • Powerful Data Manipulation: SQL provides a robust and expressive syntax for complex filtering, joining, and aggregation of data.
  • Reliability and Consistency: Relational databases, powered by SQL, are built on the principles of ACID (Atomicity, Consistency, Isolation, Durability), ensuring data integrity.
  • High Demand Skill: Proficiency in SQL is highly sought after for roles in backend development, data science, business intelligence, and data engineering.
  • Foundation for Modern Tools: Many modern data tools, libraries, and ORMs (Object-Relational Mappers) ultimately generate and execute SQL queries under the hood.
  • 1970: Dr. Edgar F. Codd, an IBM researcher, publishes his seminal paper, “A Relational Model of Data for Large Shared Data Banks,” laying the theoretical foundation for relational databases.
  • 1974: Based on Codd’s model, Donald Chamberlin and Raymond Boyce at IBM develop a query language called SEQUEL (Structured English Query Language), later shortened to SQL.
  • 1979: Relational Software, Inc. (which later became Oracle) releases the first commercially available RDBMS that uses SQL.
  • 1986-1987: SQL is officially adopted as a standard by the American National Standards Institute (ANSI) and the International Organization for Standardization (ISO), solidifying its role as the industry standard.

When you execute a SQL query, the database engine performs a series of steps to return your desired result:

  1. 1. Parsing: The engine first checks the SQL statement for correct syntax. It verifies that all keywords (SELECT, FROM, etc.) are spelled correctly and the overall structure is valid.
  2. 2. Binding (Validation): The engine checks the semantic validity of the query. It verifies that the tables and columns mentioned actually exist, and that you have the necessary permissions to access them.
  3. 3. Optimization: This is the most critical phase. The Query Optimizer analyzes the query and determines the most efficient way to execute it. It considers various “execution plans,” such as which indexes to use, the order in which to join tables, and the best algorithm for data access. This is why SQL is declarative—the optimizer handles the “how.”
  4. 4. Execution: The engine runs the chosen execution plan. It fetches data from disk into memory, performs any filtering, joining, or sorting, and prepares the final result set to be sent back to the client.

This process ensures that even complex queries are executed as efficiently as possible, abstracting the low-level data retrieval logic away from the user.