Skip to content
IGCSE·Tuition
Computer Science · Topics

Databases and query reasoning

Database questions look short, but one misplaced bracket or wrong field name changes the whole result.

On this page
  1. What should you already know?
  2. An orienting example
  3. In what order should you study the lessons?
  4. Which traps catch most students?
  5. How should you use the practice set?

This module is about storing data in a table and asking questions of it. You will name the parts of a table, choose a key that identifies each record, write a SELECT query with a condition, combine conditions correctly, and explain why a query returns nothing.

Check the current Cambridge Computer Science 0478 syllabus for the exact query features in your exam year. Our Computer Science learning guide shows where this module sits among the others.

What should you already know?

You need to read a table of rows and columns and to compare values with =, < and >. Basic Boolean ideas help too: AND needs both conditions true, OR needs at least one. Boolean and number-representation lab lets you try those on small examples.

An orienting example

A fictional plant shop stores its stock in a table called Plants. All the lessons in this module reuse it.

PlantIDNameTypePriceStockIndoor
P01FernFoliage12.508TRUE
P02CactusSucculent6.0025TRUE
P03RoseFlowering15.000FALSE
P04MintHerb4.5040FALSE
P05OrchidFlowering28.003TRUE
P06BasilHerb5.0012FALSE
P07AloeSucculent9.5015TRUE
P08HibiscusFlowering18.006FALSE

Question: which flowering plants are in stock?

SELECT Name
FROM Plants
WHERE Type = "Flowering" AND Stock > 0

Check each record.

Rose is flowering but Stock is 0, so it fails. Orchid (3) and Hibiscus (6) pass both conditions. The result is two rows: Orchid and Hibiscus.

In what order should you study the lessons?

  1. Distinguish field, record and table: every later lesson uses these words, so fix them first.
  2. Choose a suitable key: a key explains why each record can be found exactly once.
  3. Write a simple SELECT filter: the core skill, one condition at a time.
  4. Combine conditions with the correct Boolean grouping: AND, OR and brackets change which rows survive.
  5. Explain why a query returns no rows: reasoning that checks a query against the data.

Then test yourself with the original practice set. The read-only SQL practice lab runs safe SELECT queries on a fictional database.

Which traps catch most students?

  • Writing a text value without quotation marks, or using the wrong spelling of a field name.
  • Mixing up the columns you display (SELECT) with the columns you test (WHERE).
  • Forgetting that AND is stricter than OR, so adding AND can only remove rows.
  • Reading > as “at least”: Price > 28 excludes a plant priced exactly 28.00.

How should you use the practice set?

Cover the answer, write the query or result yourself, then check row by row against the table. Log each wrong answer with its cause in the mistake log so the same slip does not return. For tuition built around this topic, see our online one-to-one Computer Science tuition.

Sources

  1. Cambridge IGCSE Computer Science 0478 syllabus page

Updated:

Your next step

If you can read a query in class but still pick the wrong rows in an exam, a one-to-one teacher can work through your queries row by row and find the exact condition that misleads you.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parent or guardian? Enquire here

9,000+ students helped through our service