Welcome to the SQL Basics course! This hands-on curriculum will teach you essential SQL skills using a Star Wars-themed database. By the end of this course, you'll be able to create, query, and manage relational databases with confidence.
| Lesson | Topic | Jupyter Notebook | Markdown | Solutions | |
|---|---|---|---|---|---|
| 1 | Introduction to Databases & SQLite Setup | π Notebook | π Markdown | π PDF | π ipynb π sql |
| 2 | Selecting and Filtering Data (SELECT & WHERE) | π Notebook | π Markdown | π PDF | π ipynb π sql |
| 3 | Sorting and Limiting Results | π Notebook | π Markdown | π PDF | π ipynb π sql |
| 4 | Aggregate Functions and GROUP BY | π Notebook | π Markdown | π PDF | π ipynb π sql |
| 5 | Multiple Tables and Relationships | π Notebook | π Markdown | π PDF | π ipynb π sql |
| 6 | Table Joins | π Notebook | π Markdown | π PDF | π ipynb π sql |
| 7 | Updating and Deleting Data | π Notebook | π Markdown | π PDF | π ipynb π sql |
| 8 | Advanced Queries with Subqueries | π Notebook | π Markdown | π PDF | π ipynb π sql |
| 9 | Python Database Integration | π Notebook | π Markdown | π PDF | π ipynb π py |
| 10 | ORM & Non-SQL Overview | π Notebook | π Markdown | π PDF | π ipynb π md |
Choose Your Format:
- π Jupyter Notebooks - Interactive, run code directly (Recommended)
- π Markdown - Easy to read, copy code to separate files
- π PDF - Print-friendly, perfect for offline study
Each lesson follows this format:
- Learning Objectives - What you'll master
- Activities - Step-by-step exercises
- Deliverables - Files you'll create
- Challenge Problem - Test your skills
Duration: 20 minutes
Create your first database and insert Star Wars characters.
Key Concepts: CREATE TABLE, INSERT INTO, Primary Keys
Activities:
- Database concepts (3 min)
- Create
starwars.dbin thedatabasefolder andcharacterstable (10 min) - Insert 5-8 characters (7 min)
Deliverables: lesson1_setup.sql
Duration: 20 minutes
Query data and filter results with conditions.
Key Concepts: SELECT, WHERE, Comparison Operators, LIKE
Activities:
- SELECT basics and WHERE clause (8 min)
- Comparison operators (=, !=, >, <) (5 min)
- Pattern matching with LIKE (7 min)
Deliverables: lesson2_queries.sql
Duration: 20 minutes
Control query output with sorting and limits.
Key Concepts: ORDER BY, LIMIT, OFFSET
Activities:
- ORDER BY ASC/DESC (8 min)
- LIMIT and pagination (5 min)
- Combined queries (7 min)
Deliverables: lesson3_sorting.sql
Duration: 20 minutes
Perform calculations on grouped data.
Key Concepts: COUNT, AVG, MAX, MIN, GROUP BY, HAVING
Activities:
- Aggregate functions (8 min)
- GROUP BY clause (7 min)
- HAVING for filtering groups (5 min)
Deliverables: lesson4_aggregates.sql
Duration: 20 minutes
Design a multi-table database with foreign keys.
Key Concepts: Foreign Keys, One-to-Many Relationships
Activities:
- Relationship concepts (5 min)
- Create
planetsandvehiclestables (10 min) - Insert related data (5 min)
Deliverables: lesson5_schema.sql, lesson5_data.sql
Duration: 20 minutes
Combine data from multiple tables using joins.
Key Concepts: INNER JOIN, LEFT JOIN
Activities:
- JOIN concepts and syntax (5 min)
- INNER JOIN practice (8 min)
- LEFT JOIN and NULL handling (7 min)
Deliverables: lesson6_joins.sql
Duration: 20 minutes
Modify and remove data safely.
Key Concepts: UPDATE, DELETE, WHERE (critical!)
Activities:
- UPDATE operations (8 min)
- DELETE operations (7 min)
- Safety practices and constraints (5 min)
Deliverables: lesson7_modifications.sql
Duration: 20 minutes
Write complex nested queries.
Key Concepts: Subqueries, IN, NOT IN, EXISTS
Activities:
- Subqueries in WHERE (10 min)
- IN and EXISTS operators (7 min)
- Practice complex queries (3 min)
Deliverables: lesson8_advanced.sql
Duration: 20 minutes
Connect to SQLite from Python and execute queries.
Key Concepts: Python sqlite3 module, Parameterized queries
Activities:
- Connection and cursor basics (8 min)
- Execute queries and fetch results (8 min)
- Parameterized queries (SQL injection prevention) (4 min)
Deliverables: lesson9_database.py
Duration: 20 minutes
Compare SQL, ORM, and NoSQL approaches.
Key Concepts: SQLAlchemy basics, NoSQL concepts
Activities:
- ORM introduction and comparison (10 min)
- NoSQL database types (8 min)
- When to use each approach (2 min)
Deliverables: lesson10_comparison.md
Learn_SQL_Basics/
βββ README.md # This file
βββ QUICKSTART_PDF.md # Quick guide for PDF conversion
βββ notes.md # Curriculum planning notes
βββ TEACHING_NOTES.md # Instructor guidance
βββ requirements.txt # Python dependencies
β
βββ database/
β βββ starwars.db # Your database (created in Lesson 1)
β
βββ lessons/ # π Interactive Jupyter Notebooks
β βββ lesson*.ipynb
β
βββ other_formats/
β βββ markdown_lessons/ # π Markdown Instructions
β β βββ lesson*_instructions.md
β βββ pdf_lessons/ # π PDF Documents (for printing)
β βββ lesson*_instructions.pdf
β
βββ solutions/ # β
Answer Keys
β βββ *.ipynb # Jupyter notebook solutions
β βββ *.sql # SQL script solutions
β βββ *.py # Python script solutions
β βββ *.md # Written explanations
β
βββ utils/ # π§ Utility Scripts
βββ md_to_pdf.py # Markdown to PDF converter
βββ install_dependencies.sh # Dependency installer
βββ convert_lessons.sh # Quick conversion script
βββ README.md # Utils documentation
Each lesson is available in three formats to suit different learning styles:
Location: lessons/
- Interactive coding environment
- Run SQL and Python code directly
- Instant feedback and results
- Best for hands-on learning
How to use:
- Navigate to
lessons/ - Open
lesson1_setup.ipynb - Follow instructions and run cells as you go
Location: other_formats/markdown_lessons/
- Step-by-step written guides
- Easy to read in VSCode or GitHub
- Great for reference
- Can copy SQL code to separate files
How to use:
- Navigate to
other_formats/markdown_lessons/ - Open
lesson1_instructions.md - Read and follow along
- Create your own
.sqlfiles in alessons/folder
Location: other_formats/pdf_lessons/
- Print-friendly format
- Professional formatting
- Perfect for offline study
- Easy to annotate
How to use:
- Navigate to
other_formats/pdf_lessons/ - Download or open
lesson1_instructions.pdf - Print or view on tablet/second screen
Location: solutions/
Complete solutions are provided for instructors and self-checking:
- Jupyter Notebooks - Interactive solutions with explanations
- SQL Files - Complete SQL scripts
- Python Files - Working Python code
- Markdown Files - Written explanations
π¨ Academic Honesty: Attempt each lesson yourself before checking solutions!
- Complete the lesson first - Give it your best effort
- Check your work - Compare with solution after attempting
- Learn from differences - Understand why the solution works
- Ask questions - If solution doesn't make sense, ask instructor
lesson1_setup.ipynb/lesson1_setup.sqllesson2_queries.ipynb/lesson2_queries.sqllesson3_sorting.ipynb/lesson3_sorting.sqllesson4_aggregates.ipynb/lesson4_aggregates.sqllesson5_schema.ipynb/lesson5_schema.sql/lesson5_data.sqllesson6_joins.ipynb/lesson6_joins.sqllesson7_modifications.ipynb/lesson7_modifications.sqllesson8_advanced.ipynb/lesson8_advanced.sqllesson9_database.ipynb/lesson9_database.pylesson10_comparison.ipynb/lesson10_comparison.md
- Type everything yourself - Don't copy/paste. Muscle memory helps learning.
- Experiment freely - The Codespace resets, so try variations without fear.
- Read error messages - They're your friends! They tell you what went wrong.
- Use the VSCode plugin - Visualize your database structure and results.
- Complete challenge problems - They prepare you for exam-style questions.
- Build incrementally - Each lesson builds on the previous one.
- Save your work - Commit changes to preserve your progress.
Want to create your own PDFs from markdown files or update existing PDFs?
bash utils/convert_lessons.shThis will automatically:
- Install required dependencies (if needed)
- Convert all markdown lessons to PDF
- Save PDFs to
other_formats/pdf_lessons/directory
Install dependencies:
bash utils/install_dependencies.shConvert all lessons:
python3 utils/md_to_pdf.py --directory "other_formats/markdown_lessons" --output-dir "other_formats/pdf_lessons"Convert single lesson:
python3 utils/md_to_pdf.py --file "other_formats/markdown_lessons/lesson1_instructions.md" --output-dir "other_formats/pdf_lessons"For more details, see utils/README.md or QUICKSTART_PDF.md
Method 1: Using the SQLite3 Editor Plugin
- Right-click on
database/starwars.db(once created) β "Open with SQLite3 Editor" - Open your
.sqlfile in the editor - Select the SQL code you want to run
- Right-click β "Run Selected Query"
- View results in the Output panel
Method 2: Quick Execute
- Open any
.sqlfile - Use keyboard shortcut (varies by OS)
- Results appear instantly
- The VSCode plugin is already installed and configured
- You can execute multiple queries at once
- Results display in a clean, tabular format
- β SQL file completeness and correctness
- β Python script functionality
- β Challenge problem solutions
- β Code organization and comments
Choose one capstone project:
- Star Wars Encyclopedia CLI - Full CRUD application with advanced features
- Database Design Challenge - Expand the database with new tables
- SQL vs ORM Performance Study - Benchmark and analyze different approaches
- SQLBolt - Interactive SQL tutorials
- LeetCode Database Problems - Practice SQL challenges
- DB Fiddle - Online SQL playground
- SWAPI - The Star Wars API - For additional data ideas
- Read error messages carefully - They usually explain the problem
- Check your SQL syntax - Typos are common
- Review previous lessons - The solution might be in earlier material
- Use the resources folder - Quick reference materials available
- Ask your instructor - We're here to help!
- Check the solutions folder - After attempting problems yourself
This course covers all required curriculum points:
β
Apply a web-based database and construct scripts that execute SQL
β
Selecting fields
β
Incorporating GROUP BY
β
Common SQL queries
β
Constraints using WHERE keyword
β
Table joins
β
Interfacing with SQL and non-SQL databases
β
Compare Object-Relational Mapping (ORM) to SQL
Focus Areas for Assessment:
- SQL syntax (primary focus)
- SELECT queries with WHERE, ORDER BY, LIMIT
- Aggregate functions and GROUP BY
- Table joins (INNER, LEFT, RIGHT)
- Subqueries
- UPDATE and DELETE operations
- Database design concepts
Less Emphasis:
- ORM (conceptual understanding only)
- NoSQL (awareness level)
- Python integration (practical skill, not exam focus)
Ready to begin your SQL journey? Start with Lesson 1 in the lessons/ folder!
Course maintained by: TempeHS
Version: 1.0
Last Updated: November 2025