Professional Documents
Culture Documents
Need for validation checks to be made on input data and types of validation checks
• In order for computer systems to only accept data inputs that ere reasonable and accurate, every item of
data needs to be examined before it is accepted by the system.
• Two different methods are use in data entry.
- Validation ensures that only data that is reasonable is accepted.
- Verification is used to check that the data does not change as it is being entered.
Validation
• Validation is the automated checking by a program that data is reasonable before it is accepted into a
computer system.
• When data is validated by a computer system, if the data is rejected a message should be output explaining
why the data was rejected and another opportunity given to enter the data.
• There are many different types of validation checks including;
- Range checks
- Length checks
- Type checks
- Presence checks
- Format checks
- Check digits
• Different types of check may be used on the same piece of data;
Ex. An examination mark could be checked for reasonableness by using a range check, type check and a
presence check
• This is used in your program as follows.
Range check
A range check checks that the value of a number is between an upper value and a lower value.
Ex. Checking that percentage marks are between 0 and100 inclusive:
1
7 Algorithm design and problem-solving
Length check
A length check checks either;
That data contains an exact number of characters;
Ex. That a password with seven or fewer characters or nine or more characters would be rejected, for
instance:
Or
That the data entered is reasonable number of characters,
Ex. A family name could be between two and thirty characters inclusive so that names with one character
or thirty-one or more characters would be rejected.
Type check
A type check checks that the data entered is of a given data type.
Ex. That the number of brothers or sisters would be an integer (whole number)
2
7 Algorithm design and problem-solving
Presence check
A presence check checks to ensure that some data has been entered and the values has not been left
blank.
Ex. An email address for an online transaction must be completed.
Format check
A format check checks that the characters entered confirm to a pre-defined pattern.
Ex. Any code / ID number must be in the form of CUB9999.
Check digit
Is the final digit included in a code; it is calculated from all the other digits in the code. Check digits are
used for barcodes, product codes, International Standard Book numbers (ISBN) and vehicle Identification
Numbers(VIN)
Check digits are used to identify errors in data entry caused by mis-typing or mis-scanning a barcode.
3
7 Algorithm design and problem-solving
In Databases we use the above mentioned Validation checks when designing tables.
Below given are how the above validations are implemented in databases.
1. Presence check makes sure that data is present in a field where it is compulsory that a value be entered.
For example, information about a student would be of little use without including an identifier such as
the student’s Admission Number.
Required: Yes
(Presence check)
2. Range checks are used to check that data is within a certain range of numbers or a specific set of values.
For example if the examination marks for a group of students were being input, a range check could be
used to make sure each mark was greater than or equal to zero and less than or equal to the maximum
possible mark.
Range Check
4
7 Algorithm design and problem-solving
3. Length checks
Length Check
5
7 Algorithm design and problem-solving
5. Format checks to ensure a data item matches a previously determined pattern and that particular
characters have particular values such as being letters or digits.
0 - A number must be typed in this position.
9 - A number may be typed in this position or it may be left blank.
L - A letter must be typed in this position.
l - A letter may be typed in this position or it may be left blank.
A - A letter or number must be typed in this position.
a - A letter or number may be typed in this position or it may be left blank.
6
7 Algorithm design and problem-solving
Verification
• Verification is checking that data has been accurately copied from one source to another – for instance, input
into a computer or transferred from one part of a computer system to another.
• Verification methods for input data include:
- Double entry
- Screen / visual checks
Double entry
- For double entry that data is entered twice, some times by different operations.
- The computer system compares both entries and if they are different outputs an error message
requesting that the data is entered again.
7
7 Algorithm design and problem-solving
British School in Colombo is planning for a drama production. The school needs a database to store
information of the cast and the costumes. You have been assigned to create a database.
tblCast
Field name Data Type
Admission Number Number
Name Text
Gender Text
Class Text
Character Text
Contact Number Text
E-mail address Text
Date Joined Date/Time
tblCostumes
Field name Data Type
Costume Number Number
Admission Number Number
Colour Text
Size Number
Price Currency
3. Apply the following validation rules and write the validation rule in the space provided.
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
8
7 Algorithm design and problem-solving
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….
……………………………………………………………………………………………………….