26 min read
Validation
The library can refuse a blank name, a nonsense date, or a city that is not on the list — before the row is saved.
A database can store a value that is the right kind of thing and still be useless. A date field will accept 14 May 2027. That is a date. It is not a sensible return date for a book borrowed in May 2026.
The staff should not have to notice every mistake after it has already been saved. The software can check the value as it is typed, and refuse it if it fails a rule.
That check is validation. Validation means: test the value against a rule before you accept it.
The usual kinds of check
Most beginner checks fall into a short list.
Required fields. The box must not be empty. FullName is required at Riverside Public Library. A note field might be allowed to stay blank.
Uniqueness. No two members share the same MemberID. Some fields, such as a locker number, must not repeat.
Ranges. A fine cannot be negative. A return date must fall within a sensible window — not a year in the future.
Formats. A UK mobile number has a leading 0 and groups of digits. The software can demand that shape without knowing whose number it is.
Allowed values. City must be one of a known set. The person picks York; they cannot invent Yrk.
Two fields together. ReturnDate must be after LoanDate. That rule looks at two boxes on the same row.
| Rules written in ordinary English | ||
|---|---|---|
Validation vs integrity
These ideas overlap, but they are not the same word for the same job.
Validation is a check at the door. It runs as data is entered. Required, list, range, format — validation refuses nonsense before the row is saved.
Data integrity is the wider goal: stored values stay complete and consistent. Domain integrity, entity integrity, and referential integrity are all part of it.
Validation is one tool that helps integrity. Referential integrity is another. You can pass validation — York is on the list — and still store the wrong city if the form said Leeds. Validation catches nonsense. It does not catch every lie that still fits the list.
Validation vs integrity
| Validation | Integrity (broader) |
|---|---|
| Refuses a blank FullName as you type | Includes entity integrity — every row has a unique primary key |
| Refuses Yrk because it is not on the city list | Includes domain integrity — legal values for each field |
| Refuses 14 May 2027 as a return date | Includes referential integrity — MemberID 99 is refused |
| Runs when data is entered | Describes the whole habit of keeping data trustworthy |
Practice
Swipe or use the arrows to move between questions.
1 / 3
Section check
Before you continue: integrity
Domain rules, entity rules, referential rules, and validation — what should the software refuse?
This is practice, not the final assessment. Use hints. Look up a lesson if you are unsure — there is no score.
Self-check
Click every invalid cell.
| George's typing | ||
|---|---|---|
Self-check
Self-check
Self-check
More lessons in Database Fundamentals · Next: Redundant Data and Anomalies · Previous: Orphan Records and Referential Integrity
