HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Computer Science
  2. /Algorithms, Programming and Logic
  3. /Databases and SQL

Databases and SQL

Computer Science · High School (9–10) · 3 courses, 30 worked problems, 30 practice questions

A database stores data in an organised way so that it can be searched quickly. In a single-table database, each row is a record, such as one student, and each column is a field, such as a name or a date of birth. Each field has a data type, and the primary key is a field that is unique for every record. SQL is the language used to ask questions of a database. A query such as SELECT name FROM students WHERE age > 15; picks out the records you need. ORDER BY sorts them, and SUM and COUNT give totals.

With practice you will be able to

  • Choose fields, data types and a primary key for a table
  • Write an SQL query with SELECT, FROM and WHERE
  • Sort and count records with ORDER BY, SUM and COUNT

On the syllabus of

  • IGCSE

Lessons

  • Database Tables, Data Types and Primary KeysWhy should a phone number not be stored as a number? Why must one field never repeat?High School (9–10)
  • SQL Queries: SELECT, WHERE and ORDER BYHow do you ask a database for only the records you want? How do you show the newest first?High School (9–10)
  • SQL: SUM, COUNT, AND, OR and Reading Query OutputCan one line of SQL count the records for you? How do you find members under 12 or over 65?High School (9–10)

Practice questions

Choose an answer, then check it. Each one shows a full explanation.

A club table keeps one row for each member. What do we call the row that holds every detail about one member?

A park keeps a table Trees with the fields TreeID, Species, HeightM and Planted. There is one row for each of the 9 trees in the park. How many records and how many fields does the table have?

A field Wheelchair records whether a seat in a theatre has space for a wheelchair. Which data type suits it best?

Worked problems

Each one has a hint, the key idea and a full worked solution.

  • A school library keeps its books in a table called Books…Easy
  • A cinema wants a single-table database of its films…Medium
  • A delivery company has a table Customers with the fields CustomerID, FullName and Address…Medium
  • A sports day table has these fields. Suggest a suitable data type for each one…Easy

Python labs

  • Build a table with a primary key
  • Validation checks before a record is stored
  • Choosing records with WHERE
  • Sorting with ORDER BY
  • Counting and adding up sales
  • Two conditions with AND and OR

Related topics

  • Algorithms, Programming and Logic
  • Algorithms and Problem-Solving
  • Boolean Logic
  • Programming

A field Grade always holds exactly one letter, from A to E. Which data type suits it best?

A field Mobile stores phone numbers such as +33 6 12 34 56 78. Which data type should it have, and why?

A cycle club stores its bikes in a table. The fields are FrameNo, Colour, Owner and Gears. The records are (FR8841, Red, Kofi, 21), (FR2093, Blue, Ana, 7), (FR5520, Red, Lee, 21) and (FR7716, Green, Ana, 3). Which field is the most suitable primary key?

A field Percentage must hold a whole number from 0 to 100. A clerk types 140. Which validation check rejects it?

A field ClassCode must be two capital letters followed by two digits, such as KT48. Which validation check makes sure each code follows this pattern?

A youth club takes members aged from 16 to 19 years. A tester picks ages to try on the range check: both limits, and one age just beyond each limit. Which choice is right?

A table Results has the fields StudentID, Subject and Mark. The records are (S1, Maths, 72), (S1, Art, 64), (S2, Maths, 58) and (S3, Art, 72). Which of these is true?

All 30 practice questions on Databases and SQL →

A garden centre stores its plants in this table…
Medium
  • A shop gives every product a code: the letter P followed by a fixed number of digits, such as P0427…Hard
  • A student designs a table of club members and stores the phone number 07700 900814 in a field Phone…Medium
  • A hotel stores its bookings in a table. For each field, choose one suitable validation check and…Easy
  • A table of part-time jobs has a field HoursPerWeek…Medium
  • A hotel validates each booking before it is added…Hard
  • A stationery cupboard keeps its pens in a table Pens…Easy
  • A student wants the name and the price of every product in a shop table called Products. He writes…Medium
  • All 30 worked problems on Databases and SQL →