Validate database field values
Choose checks that keep entered values consistent with a field's type and stated requirements.
Section 9 · Databases
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6, Topic 9. It covers single-table databases only and the specified SELECT, FROM, WHERE, ORDER BY, SUM, COUNT, AND and OR content. The official specimen also demonstrates NOT in a filter. Multi-table joins, GROUP BY, database implementation and the separate 2029–2031 syllabus are not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding.
Before you begin
- Be able to read a small table and compare values. Each lesson introduces the database and SQL terms it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
What is a presence check for?
What you will learn
- Explain the purpose of database validation
- Match a validation check to a field
- Use range, presence and format rules appropriately
Validation protects the table's meaning
Validation checks whether an entered value is acceptable for a field before it is stored. It helps prevent values that contradict the field's type or stated limits.
For example, a required BookingID should not be blank, a seat count should be a whole number, and a date should follow the accepted date format.
Choose a check from the requirement
A range check can keep a score within its permitted interval; a format check can require a code to follow a pattern; a presence check can require an essential value.
Validation cannot prove that a value is true in the real world. It checks form or rules, so a well-formatted name or date may still be incorrect.
Pause and explain
A rating must be from 1 through 5 inclusive. Which check directly enforces this?
Worked example
A field stores a rating from 1 to 5 and is required. Suggest two validation checks.
Show the worked solution
- The value must fall within the allowed interval.
- The field must contain a value.
- Use checks that address each requirement separately.
Answer Use a range check of 1–5 and a presence check.
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
A required email field must include a value, and a course code must match two letters followed by three digits. Suggest checks.
Give me a hint
Match presence to required data and format to the pattern.
Compare my reasoning
- Require a non-empty email value.
- Check the course code's character pattern.
- Do not treat a matching pattern as proof the address or code exists.
Use a presence check for email and a format check for the course-code pattern.
Look for these in your work
- Required check
- Format check
- Validation limitation
A value field accepts integers from 0 to 100 inclusive. Give a suitable range check and two boundary values to test it.
Give me a hint
The endpoints are accepted.
Compare my reasoning
- Set the lower limit to 0 and upper limit to 100.
- Try 0 and 100.
- Also test nearby rejected values if checking the rule thoroughly.
Accept values 0–100 inclusive; boundary tests include 0 and 100 (and −1 or 101 as rejected neighbors).
Look for these in your work
- Inclusive bounds
- Boundary values
A date passes a format check but names the wrong month. Explain what the validation check proves and what it does not.
Give me a hint
A format rule checks structure, not real-world correctness.
Compare my reasoning
- The text matches the expected shape.
- It may still encode an unintended or incorrect date.
- Use an additional rule or user confirmation when the requirement needs stronger assurance.
The format is acceptable, but the check alone does not prove the intended date is correct.
Look for these in your work
- Check scope
- Truth limitation
Common mistakes
- Calling a valid format proof that the value is true
- Choosing a range that excludes a valid endpoint
- Applying the same check to fields with different requirements
What can you explain now?
What does validation decide?
Compare with the explanation
Whether data satisfies defined rules
Validation checks acceptability against the field's requirements.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
Why does a successful validation check not guarantee that a value is true?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.