Skip to content
Computer Science · 11th Grade · Data Structures and Management · Weeks 1-9

SQL: Querying and Manipulating Data

Students will learn to write basic SQL queries to retrieve, insert, update, and delete data.

Common Core State StandardsCSTA: 3B-DA-05

About This Topic

SQL (Structured Query Language) is the standard language for interacting with relational databases and one of the most consistently in-demand technical skills across data analysis, software engineering, and business roles. This topic addresses CSTA standard 3B-DA-05 and introduces 11th-grade students to the four core data manipulation operations: SELECT for retrieval, INSERT for adding records, UPDATE for modifying them, and DELETE for removing them. Mastering basic SQL gives students immediate practical capability that transfers directly to internships, college courses, and career work.

In the US K-12 context, SQL is valuable both as a programming skill and as a tool for computational thinking. Writing queries forces students to think precisely about what data they want, under what conditions, and from which tables. The WHERE clause in particular builds logical reasoning skills that connect to Boolean algebra and conditional logic from earlier units.

Active learning is a strong fit for SQL because the immediate feedback of running a query and seeing results creates a tight learning loop. Structured practice with realistic datasets in pairs or small groups produces richer learning than individual drill, since students catch each other's syntax errors and develop intuition about query behavior through comparison.

Key Questions

  1. Construct SQL queries to perform basic data manipulation (SELECT, INSERT, UPDATE, DELETE).
  2. Analyze the impact of different WHERE clauses on query results.
  3. Differentiate between various SQL join types and their applications.

Learning Objectives

  • Construct SQL queries using SELECT, INSERT, UPDATE, and DELETE statements to manipulate data in a relational database.
  • Analyze the results of SQL queries by applying various conditions in WHERE clauses.
  • Compare and contrast different SQL join types (e.g., INNER JOIN, LEFT JOIN) to retrieve data from multiple related tables.
  • Evaluate the impact of DELETE and UPDATE statements on database records, predicting the outcome before execution.

Before You Start

Introduction to Databases and Tables

Why: Students need a basic understanding of how data is organized into tables with rows and columns before learning to query it.

Basic Data Types (Text, Numbers, Dates)

Why: Familiarity with data types is essential for understanding how to correctly insert, update, and query data within database fields.

Key Vocabulary

SELECTAn SQL statement used to query and retrieve data from one or more tables in a database.
INSERTAn SQL statement used to add new rows or records into a database table.
UPDATEAn SQL statement used to modify existing records within a database table.
DELETEAn SQL statement used to remove one or more records from a database table.
WHERE clauseA clause in SQL statements that specifies conditions for filtering records, limiting the rows affected by the query.
JOINAn SQL clause used to combine rows from two or more tables based on a related column between them.

Watch Out for These Misconceptions

Common MisconceptionSELECT * is fine for any query.

What to Teach Instead

Selecting all columns is convenient during exploration but retrieves more data than needed, increasing query time and network load. In production systems, explicitly listing needed columns is a best practice. This habit also makes code more readable and less fragile when table schemas change over time.

Common MisconceptionDELETE removes only the rows you intend.

What to Teach Instead

DELETE without a WHERE clause removes every row in the table, which has caused significant data loss in real systems. Students should develop the habit of writing and verifying the WHERE clause before adding DELETE, and of testing deletion intent with a SELECT statement first.

Common MisconceptionSQL clauses can appear in any order in a query.

What to Teach Instead

SQL has a required clause order: SELECT, FROM, JOIN, WHERE, GROUP BY, HAVING, ORDER BY. Writing clauses out of order produces syntax errors. Students often confuse this because the logical intent of a query does not naturally match the required syntax order, so explicit practice with clause ordering is worthwhile.

Active Learning Ideas

See all activities

Real-World Connections

  • Database administrators at companies like Amazon use SQL daily to manage vast product catalogs, customer information, and order histories, ensuring data integrity and efficient retrieval.
  • Financial analysts at investment firms query large datasets using SQL to identify market trends, track portfolio performance, and generate reports for clients.
  • Web developers utilize SQL to interact with backend databases for applications like social media platforms, storing and retrieving user profiles, posts, and comments.

Assessment Ideas

Quick Check

Provide students with a simple table schema (e.g., students and courses). Ask them to write an SQL query to: 1. Select all students from a specific grade. 2. Insert a new student record. 3. Update a student's course enrollment. 4. Delete a student record. Review their queries for correct syntax and logic.

Exit Ticket

Present students with two related tables (e.g., 'Employees' and 'Departments'). Ask them to write an SQL query using an INNER JOIN to list employee names and their corresponding department names. Then, ask them to explain in one sentence why a JOIN was necessary.

Discussion Prompt

Pose a scenario: 'You need to find all customers who have placed an order in the last month, but you also want to see their full address. Which SQL clauses would you use, and why is the WHERE clause critical here?' Facilitate a brief class discussion on query construction and filtering.

Frequently Asked Questions

What does SQL stand for and what is it used for?
SQL stands for Structured Query Language. It is the standard language for creating, querying, and manipulating relational databases. SQL is used by developers, data analysts, and business intelligence professionals to retrieve specific data, insert new records, update existing data, and delete records. It is one of the most widely used technical skills across data and software roles.
What is the difference between WHERE and HAVING in SQL?
WHERE filters rows before any grouping or aggregation occurs, while HAVING filters groups after a GROUP BY operation. WHERE filters individual records, while HAVING filters aggregated results like classes with an average grade above 80. Understanding the execution order is essential for writing queries that combine filtering with aggregation.
What are SQL joins and when are they used?
Joins combine rows from two or more tables based on a related column. An INNER JOIN returns only rows where the join condition matches in both tables. A LEFT JOIN returns all rows from the left table plus matching rows from the right, with NULL for non-matching rows. Joins are essential for querying normalized databases where related data is spread across multiple tables.
What active learning strategies work best for teaching SQL?
Query challenge activities using realistic sample databases let students connect syntax to meaningful questions from the start. Paired query writing, where students write queries for each other to solve, deepens understanding of semantics because students must think from both sides. Prediction exercises before running queries build the habit of reasoning about expected results first, which translates directly to professional debugging practice.