/en-tutor-prep-igcse-cs-databases-fields-records-primary-key-sql/
/en-tutor-prep-igcse-cs-databases-fields-records-primary-key-sql/
General Inquiry: info@TutorZone.com.hk
Office Hours: Monday to Saturday - 9:00 AM to 6:00 PM
WhatsApp Monday to Sunday - 24 hours
Hotline: +852 6828 1809
Instant Support: +852 9061 3106

IGCSE Computer Science: Databases, Primary Keys and SQL — Tutor Prep Guide

IGCSE Computer Science: Databases, Primary Keys and SQL — Tutor Prep Guide

  • 2026-11-27

Students think a database is just a table, so a written requirement does not turn into fields, and SQL is only a sentence to memorise. This chapter takes eight loan records and seven fields, translates the requirement into a table, uses three tests to show why the loan number is the primary key, then runs nine SQL keywords five times on the same table and reads every output aloud.

Objectives — Students can: (1) turn a loan requirement into 7 fields and give one validation method for each; (2) choose the right one of the six basic types for each field and explain character against text; (3) apply the three tests of unique, always present and never changing to pick a primary key and say why the borrower fails; (4) work out that 8 records times 7 fields is 56 values, 20 seconds each, which is 18.7 minutes; (5) write queries with nine keywords and read back the three rows for five days late or more.

01 Prerequisites (3-minute check)

If any of these fails, fix it before the lesson starts.

Skill Quick check Pass mark
Fields and records What is one column of a table called, and one row? A column is a field, a row is a record
Integer and real Should 3 days late and a 1.50 fine be stored as the same type? 3 is an integer and 1.50 is a real, so no
Unique values Two students share a name. Do they share a student number? No, the number is designed to be different for each

02 Lesson flow (60 minutes)

Time Stage Tutor does Student does
0-10 min Requirement to fields Split a loan requirement into seven fields One field holds one value
10-18 min Records and workload Count 8 records and 56 values 1,120 seconds, which is 18.7 minutes
18-28 min Six data types Match each field to a type text, character, Boolean, integer, real, date/time all placed
28-38 min Three tests for a key Reject borrower and title Only the loan number passes all three
38-52 min Nine SQL keywords Run five queries on the table and write the output WHERE picks rows, ORDER BY sorts
52-60 min Sum and count Average the fine from SUM and COUNT 14.00 divided by 8 is 1.75

03 Teaching script (read it out)

Scene 1: From a requirement to one table – fields, records and validation

The question gives a requirement such as: the library must record each book lent, who borrowed it, the date, the days late and the fine. Fields come out of that sentence, and the rule is one value per field: the borrower is one field, and a whole sentence about who borrowed what on which day cannot sit in one cell.
The demonstration table has 7 fields: loan number, borrower, title, date out, days late, fine and waived. 8 records are 8 rows, and 8 times 7 is 56 values; at 20 seconds a cell that is 1,120 seconds, or 18.7 minutes. That number answers why a database beats copying by hand: the same data retyped every time multiplies by this cost.
Validation belongs to a field, and a specific answer earns the mark: a range check on days late from 0 to 14, a presence check and a length check of up to 20 characters on the borrower, a format check of DD/MM/YYYY on the date, and a type check of integer on the loan number.
Field against record in one sentence: a field is what this kind of data is called, a record is everything about one object. Asked how many fields one record holds, the answer is 7.

Field What it stores Type Validation
LoanID one number per loan integer type check: must be a whole number
Borrower name in letters and spaces text/alphanumeric presence check and a length check of up to 20 characters
Title the book title text/alphanumeric presence check
DateOut day, month and year date/time format check (DD/MM/YYYY)
DaysLate whole number from 0 to 14 integer range check (0 to 14)
Fine days late times 0.50 real range check (0.00 to 7.00)
FineWaived whether the fine is waived Boolean type check (TRUE or FALSE only)

Students turn a requirement for lending instruments to students into six fields, give one validation each, and say how many values one record holds.

Scene 2: Six basic types and the primary key – why the loan number

The 0478 list has only six names, so answers must use its words rather than int and float: text/alphanumeric, character, Boolean, integer, real and date/time.
Character is the trap: it holds a single character, so a borrower name is never character, while a shelf code A, B or C is. Only text/alphanumeric holds a string of letters and digits.
A primary key passes three tests: every record differs (unique), every record has a value (never blank), and the value never changes once written. Running the tests: the loan number passes all three; the 8 records hold only 5 different borrowers, since Chan TM, Lee KY and Wong SS each appear twice, so the borrower is not unique; the title Database Basics appears 2 times, so it is not unique either; the date out repeats on 05/11 in two records.
The answer is that the loan number is the primary key because every record has a different number, every record has one, and it never changes, plus a sentence that the borrower cannot be the key because one person may borrow more than one book. Sometimes two fields together are needed for uniqueness, but 0478 questions usually supply a number field, and that is the one to choose.

Type Meaning Written as Field here
text/alphanumeric letters, digits and spaces Chan TM, Database Basics Borrower, Title
character one character only ‘A’, ‘M’ none here; a shelf code A, B or C would use it
Boolean true or false only TRUE, FALSE FineWaived
integer a whole number 8, 0, 14 LoanID, DaysLate
real a number with a fraction 1.50, 14.00 Fine
date/time a date or a time 05/11/2026 DateOut

Students pick a type for a shelf code A, B or C and for a borrower name, then explain why they differ.

Scene 3: Nine SQL keywords – five queries on one table

The 0478 SQL list is only 9 keywords: SELECT, FROM, WHERE, ORDER BY DESCENDING, ORDER BY ASCENDING, SUM, COUNT, AND and OR. There is no AVG, no GROUP BY, no JOIN and no DISTINCT, and nothing that inserts, updates or deletes; an average is worked out by hand from a SUM and a COUNT.
The shape is fixed: SELECT picks fields, FROM names the table, WHERE filters rows and ORDER BY sorts. ORDER BY always comes last, so putting it before WHERE is wrong every time.
Read each of the five outputs aloud: the first picks only the title where days late is zero, which is two rows; the second picks two fields where days late is five or more, sorted by fine from largest, so Ng PF at 5.00 comes first; the third sums the fines that qualify, giving 11.00; the fourth counts the qualifying records, giving 2; the fifth joins two borrowers with OR and returns three rows, because OR keeps duplicates.
SUM against COUNT must be nailed down: SUM adds the values in a field, COUNT counts the records. The whole table adds up to 14.00, and divided by 8 records the average is 1.75, a step SQL cannot do here, so the two results are divided by hand.

SQL statement Output on the demonstration table
SELECT Title FROM Loans WHERE DaysLate = 0 Database Basics; Boolean Logic (two rows)
SELECT Borrower, Fine FROM Loans WHERE DaysLate >= 5 ORDER BY Fine DESCENDING Ng PF 5.00; Wong SS 3.50; Ho MC 2.50
SELECT SUM(Fine) FROM Loans WHERE DaysLate >= 3 11.00
SELECT COUNT(LoanID) FROM Loans WHERE Title = ‘Database Basics’ 2
SELECT Borrower FROM Loans WHERE Borrower = ‘Chan TM’ OR Borrower = ‘Ng PF’ Chan TM; Chan TM; Ng PF (three rows, OR keeps duplicates)

Students write a query for three to seven days late sorted by title from A to Z, then write out the three rows it returns.

04 Question types and worked steps

Type Example Steps Answer
Name the fields List the fields for a library loan requirement One value per field, written out 7: number, borrower, title, date, days late, fine, waived
Choose types Days late, fine, date out, waived Match integer, real, date/time and Boolean integer, real, date/time, Boolean
Choose a key Eight records, two of them Chan TM Apply unique, always present, never changing The loan number; the borrower is not unique
Write and read SQL SELECT Borrower, Fine FROM Loans WHERE DaysLate >= 5 ORDER BY Fine DESCENDING Filter rows, sort, then write each row Ng PF 5.00; Wong SS 3.50; Ho MC 2.50
Sanity check (teach this): Rationality checks: (1) the six types are text/alphanumeric, character, Boolean, integer, real and date/time, and the names must match; (2) character holds one character only, so names and titles are text; (3) a primary key needs unique, always present and never changing, all three said together; (4) ORDER BY always follows WHERE; (5) SUM adds values and COUNT counts records, so they never swap; (6) OR keeps duplicates, so two Chan TM loans are two rows; (7) 0478 has no AVG, GROUP BY or JOIN, so an average is SUM divided by COUNT by hand; (8) 8 times 7 is 56 values at 20 seconds, which is 18.7 minutes, never 15.

05 Independent practice (3 questions)

Question Answer What to watch
What does SELECT COUNT(LoanID) FROM Loans WHERE Title = ‘Algorithms’ return? 2 Check whether COUNT was treated as a sum
What does SELECT SUM(Fine) FROM Loans WHERE Borrower = ‘Wong SS’ return? 4.00, from 3.50 plus 0.50 Check whether the second record was missed
8 records and 7 fields at 20 seconds a cell. How many minutes? 56 values, 1,120 seconds, so 18.7 minutes Check whether records and fields were added

06 Common mistakes and what to say

Mistake Student writes Say this
Borrower as the primary key The borrower is the key because a person is unique Chan TM appears twice, and a key must differ on every record, so the loan number is the one that passes all three tests.
Name typed as character Borrower has type character Character holds one character only, and a name holds many, so it is text/alphanumeric.
ORDER BY in front SELECT Title ORDER BY Title FROM Loans The order is SELECT, FROM, WHERE, ORDER BY, so ORDER BY comes last every time.
Counting with SUM SUM(LoanID) tells you how many records SUM adds values and COUNT counts records, and the two answers mean different things.

07 Homework (paper, section and question numbers)

08 Exit check (last 5 minutes)

Question Answer Decision
Six types text, character, Boolean, integer, real, date/time Cannot say it, return to act two
Three key tests unique, always present, never changing Cannot say it, return to the middle of act two
SQL order SELECT, FROM, WHERE, ORDER BY Cannot say it, return to act three

09 Tutor FAQ

Students memorise the SQL shape and freeze when a condition changes. What works?

Run every statement on the same table and demand the row count and the rows themselves. The shape is only a skeleton; the marks sit in the output, where WHERE sets the rows, ORDER BY sets the order, and SUM or COUNT decides whether the answer is a number or a list. Change one condition and ask again, and students stop reciting and start reading the table.

Why not teach AVG or GROUP BY?

Because the 0478 list holds only nine keywords, and the paper will not use syntax outside it. Teaching more risks a student writing a word the mark scheme does not accept. An average comes from dividing the SUM result by the COUNT result by hand, which is the arithmetic the question actually tests.

Is a primary key the same as a unique field?

Unique is only one of three tests. A primary key also has a value on every record and never changes after it is written. A field can be different on every record and still be a poor identifier if it can be edited, such as a phone number. Saying all three tests in order is safer than saying unique alone.

Find a tutor — freeTutor Registration →

A TutorZone lesson-prep guide. Written by the TutorZone team; questions and lesson flow are original and are not taken from any school or publisher material.

Join as a tutor or coach — academic, music, sports, arts, STEM. Free to register. See how it works →