The Querynomicon

An Introduction to SQL for the Cautious and Weary

Advent 215 by Danielle Navarro

Upon first encountering SQL after two decades of Fortran, C, Java, and Python, I thought I had stumbled into hell. I quickly realized that was optimistic: after all, hell has rules.

I have since realized that SQL does too, and that they are no more confusing or contradictory than those of most other programming languages. They only appear so because it draws on a tradition unfamiliar to those of us raised with derivatives of C. To quote Terry Pratchett, it is not mad, just differently sane.

Welcome, then, to a world in which the strange will become familiar, and the familiar, strange. Welcome, thrice welcome, to SQL.

This lesson notes and working examples for instructors to use as a starting point. We do not expect novices with no prior SQL experience to be able to learn from this on their own. As a musical analogy, these notes are the chord changes and melody; we expect instructors to create an arrangement and/or improvise over the material when delivering it. Please see Teaching Tech Together for background.

Start where you are
Use what you have
Help who you can

Syllabus

  1. Introduction: where we're going and why
  2. Core Features: getting values from tables
  3. Tools: Miscellaneous things that make life easier
  4. Advanced Features: when you need 'em, you need 'em
  5. Python: using databases from Python
  6. R: using databases from R
  7. PostgreSQL: client-server computing and permissions
  8. Conclusion: where we've been and what comes next

Appendices

  1. Bibliography
  2. Glossary
  3. License
  4. Code of Conduct
  5. Contributing