SQL languages, queries and updates
SQL defines and manipulates relational data, while transactions protect consistency when multiple changes occur.
What you need to be able to do
- OutlineThe differences between data language types within SQL
- ConstructQueries between two tables in SQL
- ExplainHow SQL can be used to update data in a database
Rapid Recall Deck
Say the answer aloud before flipping. Mark secure knowledge quickly and spend time on the gaps.
- What is the difference between DDL and DML?: DDL defines or changes database structures; DML retrieves or changes the data stored in those structures.
- Which SQL clauses/commands are central to a two-table query?: SELECT, FROM, JOIN, WHERE and related filtering/ordering clauses; the syllabus also includes DISTINCT, BETWEEN, ORDER BY, GROUP BY, HAVING, LIKE, AND, OR, and NOT.
- What does JOIN do in SQL?: It combines related rows from two tables using a relationship/condition between their columns.
- What do LIKE and the % wildcard do?: LIKE performs pattern matching; % represents any sequence of zero or more characters in the pattern.
- What is the difference between WHERE and HAVING?: WHERE filters rows before grouping/aggregation; HAVING filters groups after GROUP BY.
- Which SQL commands insert, modify, and remove records?: INSERT INTO adds records, UPDATE ... SET changes existing values, and DELETE removes records.
- Why can updating indexed columns be expensive?: The database may also need to update, rebuild, or reorganize index structures after significant changes.
Core knowledge and application
The differences between data language types within SQL
SQL defines and manipulates relational data, while transactions protect consistency when multiple changes occur.
Explain it without notes
Outline: The differences between data language types within SQL in the context of a relational database used for reporting and transactional updates.
- Data language types must include data definition language (DDL) and data manipulation language (DML)
- SQL statements to define data structures or to manipulate data
Queries between two tables in SQL
SQL defines and manipulates relational data, while transactions protect consistency when multiple changes occur.
Explain it without notes
Construct: Queries between two tables in SQL in the context of a relational database used for reporting and transactional updates.
- Queries must include joins, relational operators, filtering, pattern matching, and ordering data
- SQL commands: SELECT, DISTINCT, FROM, WHERE, BETWEEN, ORDER BY, GROUP BY, HAVING, ASC, DESC, JOIN, LIKE with % wildcard, AND, OR, NOT (note: Syntax may vary in different database systems)
Core knowledge and application
How SQL can be used to update data in a database
SQL defines and manipulates relational data, while transactions protect consistency when multiple changes occur.
Explain it without notes
Explain: How SQL can be used to update data in a database in the context of a relational database used for reporting and transactional updates.
- Insert new records (INSERT INTO), modify data (UPDATE SET), remove data (DELETE)
- The performance implications of updating data in indexed columns, and how indexes might need to be rebuilt or reorganized following significant data modifications
SQL across two related tables
DDL vs DML
DDL defines structures such as tables. DML retrieves or changes stored data.
SELECT DISTINCT s.Name FROM STUDENT AS s JOIN ENROLLMENT AS e ON s.StudentID = e.StudentID WHERE e.Score BETWEEN 80 AND 100 AND s.Name NOT LIKE 'A%' ORDER BY s.Name ASC;
This one query demonstrates a JOIN, filtering, BETWEEN, pattern matching with %, NOT, DISTINCT and ordering.
SELECT CourseID, COUNT(*) AS Enrolments FROM ENROLLMENT GROUP BY CourseID HAVING COUNT(*) >= 5 ORDER BY Enrolments DESC;
Insert
INSERT INTO STUDENT VALUES (17, 'Mina');
Update
UPDATE STUDENT SET Name='Min' WHERE StudentID=17;
Delete
DELETE FROM STUDENT WHERE StudentID=17;
Transfer to a new scenario
- Data language types must include data definition language (DDL) and data manipulation language (DML)
- SQL statements to define data structures or to manipulate data
- Queries must include joins, relational operators, filtering, pattern matching, and ordering data
- SQL commands: SELECT, DISTINCT, FROM, WHERE, BETWEEN, ORDER BY, GROUP BY, HAVING, ASC, DESC, JOIN, LIKE with % wildcard, AND, OR, NOT (note: Syntax may vary in different database systems)
- Insert new records (INSERT INTO), modify data (UPDATE SET), remove data (DELETE)
- The performance implications of updating data in indexed columns, and how indexes might need to be rebuilt or reorganized following significant data modifications
Paper 1 practice
- Outline: The differences between data language types within SQL in the context of a relational database used for reporting and transactional updates.
- Construct: Queries between two tables in SQL in the context of a relational database used for reporting and transactional updates.
- Explain: How SQL can be used to update data in a database in the context of a relational database used for reporting and transactional updates.
Finish the learning cycle
Exam preparation — main task
Complete targeted 2027 case-study research and cumulative Paper 1/Paper 2 practice. Record evidence and technical vocabulary you can use in extended responses.
Retrieval
Repeat today’s recall deck and revisit any item marked ‘Review again’.