Computer Science - 9210 OxfordAQA

Structured Query Language (sql)

Overview

A database with a million records is useless unless you can ask it a question and get the four rows you actually wanted. The language for asking is SQL, and its central idea is unusual for a programming language: you describe what you want rather than how to find it. You do not write a loop over a million records. You say which fields, from which tables, matching which condition, and the database works out the rest.

This lesson covers the commands the specification names. You will learn to retrieve data with SELECT, FROM and WHERE, including queries that draw on two tables at once; to add a record with INSERT INTO; and to edit and delete data with UPDATE and DELETE FROM. You will also learn the single most consequential detail in the whole topic, which is what happens to an UPDATE or a DELETE that is missing its WHERE clause.

Objectives

  1. Be able to use SQL to retrieve data from a relational database, using the commands:
  2. SELECT
  3. FROM
  4. WHERE. Be able to use SQL to insert data into a relational database using INSERT INTO. Be able to use the SQL commands UPDATE and DELETE FROM to edit and delete data in a database.

Mind map

This topic is mapped out so you can see how the ideas connect.

Open the mind map in the app

Lesson Note

SQL, structured query language, is the language used to work with a relational database. A statement written in it is a description of a result rather than a set of instructions for producing one, which is why the same short query works whether the table holds six records or six million.

Complete Note Available on the Green Bridge App

Get the Green Bridge CBT app on your phone or computer for the complete IGCSE library: past papers, mark schemes, mind maps, flashcards and audio lessons.

Full lesson notes with diagrams
AI-powered learning assistant
Timed mock exams marked the moment you finish
Available on Android, Windows, macOS, and Linux iOS app coming soon

Lesson Evaluation

Congratulations on completing the lesson on Structured Query Language (sql). Now that youve explored the key concepts and ideas, its time to put your knowledge to the test. This section offers a variety of practice questions designed to reinforce your understanding and help you gauge your grasp of the material.

You will encounter a mix of question types, including multiple-choice questions, short answer questions, and essay questions. Each question is thoughtfully crafted to assess different aspects of your knowledge and critical thinking skills.

Use this evaluation section as an opportunity to reinforce your understanding of the topic and to identify any areas where you may need additional study. Don't be discouraged by any challenges you encounter; instead, view them as opportunities for growth and improvement.

  1. Which SQL clause states which records a query should return? A. SELECT B. FROM C. WHERE D. INSERT INTO Answer: C
  2. Which query correctly finds the names of all cats and all birds in a table called Pet? A. SELECT Name FROM Pet WHERE TypeOfAnimal = 'Cat' AND TypeOfAnimal = 'Bird' B. SELECT Name FROM Pet WHERE TypeOfAnimal = 'Cat' OR TypeOfAnimal = 'Bird' C. SELECT Name FROM Pet WHERE TypeOfAnimal = Cat OR Bird D. SELECT Name FROM Pet WHERE TypeOfAnimal = 'Cat' OR 'Bird' Answer: B
  3. What does the statement DELETE FROM Booking do if it has no WHERE clause? A. Nothing, because a WHERE clause is required B. It deletes the first record only C. It deletes every record in the Booking table D. It deletes the Booking table's field names Answer: C
  4. Which command is used to change the value already stored in a field? A. SELECT B. INSERT INTO C. UPDATE D. DELETE FROM Answer: C
  5. In a query drawing on two tables, what is the purpose of a condition such as Pet.PetID = Appointment.PetID? A. It sorts the results into order B. It matches each record in one table with the correct record in the other C. It deletes records that appear in both tables D. It renames a field Answer: B

Work through these questions in the app

Work through these questions in the app

Practice Mock Questions

Want to practice mock questions on Structured Query Language (sql)? Download the Green Bridge CBT app to access mock questions and full practice assessments for this topic.

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning