CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →

KwickAcademy Databases and SQL · 8 min · free

SQL for Cambridge IGCSE: Single-table Databases and Queries

8 min4 KwickClipsFull text belowFree
Next lesson →Kajal Ma'am (MCA), teaching since 2004Remembered in this browser

For 0478 you need fields, records, a primary key, data types, validation checks and the SQL words SELECT, FROM, WHERE, ORDER BY, SUM and COUNT.

Follows the syllabus of: Cambridge IGCSE Grade 9 Computer Science (0478), Cambridge IGCSE Grade 10 Computer Science (0478)

On screen in this lesson

Table BOOKS

BookIDTitlePrice
B01Wings of Fire350
B02Malgudi Days199
B03Gitanjali150
B04Panchatantra250

Fields and records

Table: data about one type of thing, e.g. books
Field: one column, one item of data, e.g. Price
Record: one row, all data about one book
Single-table database: all data in one table

Primary key

A field that uniquely identifies each record
No two records can have the same value
Here: BookID, because two books can share a title
Names and prices are poor keys: they repeat

Data types

TypeHoldsExample
Text/alphanumericletters, digitsWings of Fire
Characterone characterA
Booleantwo valuesTrue
Integerwhole number250
Realdecimal number9.5
Date/timedate or time15/08/2026

Choosing a data type

Phone number: text, it may start with 0
Number of pages: integer
Is the book issued?: Boolean
Date borrowed: date/time

Validation checks

Validation: automatic check that data is sensible
Range: Price between 1 and 5000
Length: BookID exactly 3 characters
Presence: Title must not be empty
Format: BookID is a letter then two digits

Quick answers

Does validation prove data is correct?

No. It only checks that data is sensible.

Which data type suits a phone number?

Text, because it may start with 0.

KwickClips from this lesson

Short clips, one idea each. Good for revision the night before.

The full lesson, in text

Hello students, welcome to Kwickprep. In your Computer Science exam, you may get a table and an unfinished SQL script. Can you fill the gaps and predict the output? Today we will learn fields, records, keys, data types, validation, and the six SQL words your syllabus needs. Kwickprep is independent, and is not endorsed by any board, so always check your current syllabus.

Here is a single-table database for a school library, with a table called books. The first record is Wings of Fire, priced three hundred fifty rupees. The second is Malgudi Days at one hundred ninety nine. The third is Gitanjali at one hundred fifty. The fourth is Panchatantra at two hundred fifty.

Let us name the parts, because the exam uses these exact words. A table holds data about one type of thing, like books. A field is one column, holding one item of data, like the price. A record is one row, holding all the data about one book. Your syllabus only needs databases made of a single table.

Every table needs a primary key. A primary key is a field whose value is unique for every record. No two records can have the same primary key value. Here Book ID is the key, because two different books could have the same title. Names and prices make poor keys, because they can repeat.

Each field is given a data type, which says what kind of data it can store. Text, also called alphanumeric, stores letters, digits and symbols. Character stores exactly one character. Boolean stores only two values, such as true or false, or yes or no. Integer stores whole numbers. Real stores numbers with a decimal point. Date and time store dates or times.

Exams often ask you to choose the best data type for each field. A phone number should be text, because it may start with zero and we never add phone numbers. The number of pages is an integer. Whether a book is issued is Boolean, because the answer is yes or no. The date borrowed is date and time.

Wrong data can enter the table, so we add validation. Validation is an automatic check that data is sensible and allowed before it is stored. A range check makes sure a value lies between limits, like a price from one to five thousand. A length check tests the number of characters, like exactly three for Book ID. A presence check stops a field being left empty. A format check tests a pattern, like one letter followed by two digits.

There are two more checks to know. A type check makes sure the data is the right type, like a number for price. A check digit is an extra digit worked out from the other digits, as in an ISBN code on a book. But remember, validation only proves data is reasonable, not that it is correct. Checking that data was copied correctly is called verification, such as typing it twice.

Exams may ask you to write a validation check as pseudocode. This loop asks for the price. It keeps repeating until the price is at least one and at most five thousand. So an entry of zero is rejected, and the user must type the price again.

Now SQL, which stands for Structured Query Language. A query is a question we ask the database. Select lists the fields to show. From names the table. Where gives the condition a record must meet. Only books priced more than two hundred appear, so we get Wings of Fire and Panchatantra.

The condition in where uses comparison operators. A single equals sign means equal to. Less than followed by greater than means not equal to. Greater than and less than compare sizes. Greater than or equal to, and less than or equal to, also include the value itself. And, or, join two conditions together.

Order by sorts the results. A S C means ascending, smallest first, and it is the default. D E S C means descending, largest first. Here we want books under three hundred rupees, most expensive first. So Panchatantra comes first and Gitanjali comes last.

Sum adds up the values of a numeric field across the records. Here there is no where, so all four books are added. Three hundred fifty, plus one ninety nine, plus one fifty, plus two fifty, gives nine hundred forty nine.

Count tells how many records match, and the star means count whole records. Pause and predict. How many books cost more than one hundred eighty rupees? The answer is three, because only Gitanjali is cheaper.

Many questions give a script with gaps to fill. Start by reading the question and noting which fields and which records it wants. After select, write the fields to show, in the order asked. After from, copy the table name exactly as printed. Then write the condition after where, and the sort after order by.

Here is a typical question. The task is to show the title and Book ID of books costing one hundred ninety nine or more, in alphabetical order of title. Try filling the three gaps yourself now. Pause the video if you need a moment.

Here is the answer. The fields are title, then Book ID, in the order the question asked. The table is books. The sort is order by title, ascending. Notice that Malgudi Days costs exactly one hundred ninety nine, and greater than or equal to includes it. Alphabetical order puts M before P before W.

Here are common mistakes that lose marks. Showing the fields in a different order from the question. Forgetting quotes around text values, so always write Gitanjali inside quotes. Missing the commas between field names. And using sum when the question asks how many, which needs count.

Let us revise what we learned today. A field is a column, a record is a row, and the primary key is unique for every record. Choose each data type carefully, such as text for phone numbers. Validation checks include range, length, type, presence, format and check digit. And the SQL words to master are select, from, where, order by, sum and count. Practise with past paper tables and write the output before checking.

Courses that teach this

CourseUnit
Cambridge IGCSE Grade 9 Computer Science (0478)9. Databases
Cambridge IGCSE Grade 10 Computer Science (0478)9. Databases

Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.

Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.

Want a plan that actually fits your board dates?

Ask Kajal Ma'am directly, 20+ years teaching computer science. Free demo class first, no payment.

Talk to Kajal Ma'am on WhatsApp

Or see the Class 12 Computer Science course →

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →