lecture notes on validation methods

Download Report

Transcript lecture notes on validation methods

AS computing
Validation and verification
Introduction
It is important to maintain the integrity of any database of
information.
Any data item must always be the correct data type and
always follow the rules for that data.
For example, you have a field in your database called
‘NAME’ that was a text data type and up the ten characters
long. If you enter a name that was thirty characters long, the
data integrity of the database would be lost.
Validation and verification techniques are all about ensuing
that the data integrity of a database is maintained by ensuring
that only the sensible data that you want is stored in it.
Validation
Validation is the term used to ensure that only
‘sensible’ data is entered into a database.
Sensible data means that it is of the correct data type
and it follows any validation rules set up for that field.
Range check
You can set up rules to ensure that if someone enters a
number it must follow some mathematical rules, for
example, be greater then a number, or less than a number.
If a value is entered outside of this range, then a helpful
error message should be displayed.
Format check
Sometimes, especially with ID and membership, the code
is made up of a mixture of numbers and letters. For
example, a membership ID card is made up of 2 letters,
followed by 3 numbers, such as AB123.
You can set up rules that look for patterns such as
LETTER-LETTER-NUMBER-NUMBER-NUMBER.
Wrong data will not get put in the database. It will be
rejected and a helpful error message should be displayed.
Length check
In text field, you can set up rules that only accept an entry
if it is less than a certain number of characters.
For example, a field in your database called ‘COLOUR’ is
set to be less than 10 characters. If someone entered ‘Blue
white and yellow’, it would get rejected because it doesn’t
follow the validation rule.
Allowable value check
You can set up fields to only accept certain values.
For example, you might set up a text field called ‘When do
you want to leave?’. So that it can only accept Morning,
Afternoon, and Evening.
Check Digit
Commonly used on bar code, it is a technique used to see if
a number has been entered correctly.
A number, called a check digit, is placed at the end of a
code. The bar code is read and a maths formula is applied to
it. If the result is the same as the check digit, then the code
has been read correctly.
A method is called ‘modulus 11’ and is used in ISBN
numbers.
Two special cases in check digit
•If the remainder is 0, the check digit is 0
•If the remainder is 1, the the check digit is X
Check digit example
Suppose you have a number 12162?. The question mark at
the end is the check digit but what should it be?
The check digit will be calculated using ‘modulus 11’.
1
2
1
6
2
6
6
5
10
4
4
3
18
2
4
A number, staring at 2 on
the right and then working
upwards, multiplies each number
in the scanned code.
The multiplied numbers are added, to give 42. 42 is then
divided by 11. This equal 3 remainder 9. The remainder is
now subtracted from 11 to give the check digit 11 –9 = 2.
The check digit is 2.
Presence check
Some fields are more important than others and must be filled in.
For example, you have a database that stores car adverts. A
customer rings up to place an advert and the operator types the
advert into the database using a data input form. If the customer
does not know the colour of the car, it is not a disaster and so it
doesn’t need to be filled in immediately. If the customer ha
forgotten his telephone number, how can anyone contact him to
buy the car? This field cannot be left blank.
If the operator presses ENTER to enter the whole advert without
this field being filled in, a helpful error message should be
displayed.
This method is presence check.