Skip to content

SQL Mastery Textbook

A free, self-paced textbook in 8 chapters. Read a chapter, then drill it with the 239 companion flashcards using spaced repetition.

8 chapters · 239 cards · Updated

Chapters

  1. 1Foundations of SQL and Relational Databases

    SQL, or Structured Query Language, is the standardized language used to manage relational databases—databases that organize data into tables connected through defined relationships...

  2. 2Database Design and Normalization

    Designing tables thoughtfully is essential to avoid anomalies when data is inserted, updated, or deleted. Normalization is the systematic process of organizing tables to reduce red...

  3. 3Querying Data: Clauses and Filtering

    The SELECT statement is the heart of SQL data retrieval. A query begins by specifying source tables with FROM, then filters rows using WHERE, groups rows with similar values using...

  4. 4Joins and Set Operations

    Real-world queries almost always span more than one table, which is where joins come in. A JOIN combines rows from two or more tables based on a related column, typically a primary...

  5. 5Aggregates and Window Functions

    Aggregate functions summarize sets of rows. COUNT(*) tallies every row including NULLs, COUNT(column) tallies non-NULL values, and COUNT(DISTINCT column) counts unique non-NULL val...

  6. 6Data Modification and Schema Management

    Beyond reading data, SQL defines ways to create, modify, and remove both rows and the structures that hold them. The CRUD operations—Create, Read, Update, Delete—correspond to INSE...

  7. 7Programmable SQL and Advanced Features

    Beyond plain queries, SQL offers ways to encapsulate logic and reshape results. A Common Table Expression (CTE), introduced with WITH, names a subquery so that the main query can r...

  8. 8Performance, Transactions, and Operations

    Indexes are the most important tool for query performance. A B-tree index—the most common kind—supports equality and range lookups, a hash index supports only equality, a unique in...

← Back to the SQL Mastery deck