Unit 12.4A · Term 4 (Revision)

SQL Query Language Revision

This revision lesson covers SQL (Structured Query Language) — the standard language for managing and querying relational databases. You'll review DDL and DML commands, multi-table queries, and the purpose of a data dictionary.

Learning Objectives

  • 11.4.2.3 Describe the basic SQL queries: CREATE, ALTER, DROP
  • 11.4.2.4 Use SQL queries: SELECT, UPDATE, INSERT, DELETE
  • 11.4.2.5 Use SQL SELECT for data selection in multiple tables
  • 11.4.2.1 Explain the purpose of a data dictionary

Lesson Presentation

12.4A-revision-sql.pdf · Slides for classroom use

Key Concepts Review

DDL — Data Definition Language

Command Purpose Example
CREATE Create a new table CREATE TABLE Students (ID INT PRIMARY KEY, Name VARCHAR(50));
ALTER Modify an existing table structure ALTER TABLE Students ADD Age INT;
DROP Delete an entire table DROP TABLE Students;

DML — Data Manipulation Language

Command Purpose Example
SELECT Retrieve data from a table SELECT Name, Grade FROM Students WHERE Grade > 8;
INSERT Add a new record INSERT INTO Students VALUES (1, 'Ali', 10);
UPDATE Modify existing records UPDATE Students SET Grade = 11 WHERE ID = 1;
DELETE Remove records DELETE FROM Students WHERE Grade < 7;

Multi-Table Queries (JOIN)

1 INNER JOIN Example

SELECT Students.Name, Classes.ClassName FROM Students INNER JOIN Classes ON Students.ClassID = Classes.ClassID WHERE Classes.ClassName = '12A'; -- Returns names of students in class 12A -- Matches records where ClassID exists in BOTH tables

Data Dictionary

What Is a Data Dictionary?

A data dictionary is a centralized document that describes the structure of a database: table names, field names, data types, constraints, relationships, and descriptions. It serves as a reference for developers and database administrators.

Revision Tasks

Remember

List the 4 main DML commands and explain what each does.

Apply

Write SQL to: (a) create a Products table with ID, Name, Price; (b) insert 3 records; (c) select products where Price > 1000.

Apply

Write a JOIN query that shows order details with customer names from two tables: Orders and Customers.

Understand

Explain the purpose of a data dictionary and what information it contains.

Self-Check Quiz

Q1: What is the difference between DDL and DML?

DDL (Data Definition Language) defines the structure — CREATE, ALTER, DROP tables. DML (Data Manipulation Language) works with data — SELECT, INSERT, UPDATE, DELETE records.

Q2: What does INNER JOIN do?

INNER JOIN returns only the records that have matching values in both tables being joined.

Q3: What command removes a table entirely from the database?

DROP TABLE — it deletes the entire table structure and all its data permanently.