10. Validation

As well as choosing the correct data types to try to reduce the number of errors made when entering data into the database, there is another method that can be used when setting up the table. This is called 'Validation'.

It is very important to remember that Validation cannot stop the wrong data being entered, you can still enter 'Smiht' instead of 'Smith' or 'Brown' instead of 'Green' or '78' instead of '87'.

What Validation can do, is to check that the data is sensible, reasonable and allowable.

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Database Validation

Some of the types of Validation that you could set up for your database are:

Database Validation
Validation Technique Example

Type Check

If the datatype number has been chosen, then only that type of data will be allowed to be entered i.e. numbers

If a field is only to accept certain choices e.g. title might be restricted to 'Mr', 'Mrs', 'Miss' and 'Ms', then 'Dr' wouldn't be allowed.

2, 3, 4

Mr, Mrs, Miss, Ms

Brown, Green, Blue, Yellow, Red

Range Check

A shop may only sell items between the price of £10.00 and £50.00. To stop mistakes being made, a range check can be set up to stop £500.00 being entered by accident.

A social club may not want people below the age of 18 to be able to join.

Notice the use of maths symbols:

> 'greater than'

< 'less than'

= equals

>=10 AND <=50

 

>=18

Presence check

There might be an important piece of data that you want to make sure is always stored. For example, a school will always want to know an emergency contact number, a video rental store might always want to know a customer's address, a wedding dress shop might always want a record of the brides wedding date.

A presence check makes sure that a critcal field cannot be left blank, it must be filled in.

School database: Emergency contact number

DVLA database: Date test passed

Electoral database: Date of birth

Vet's database: Type of pet

Picture or format check

Some things are always entered in the same format. Think about postcode, it always has a letter, letter, number, number, number, letter and letter e.g. CV43 9PB. There may be the odd occasion where it differs slightly e.g. a Birmingham postcode B19 8WR, but the letters and numbers are still in the same order.

A picture or format check can be set up to make sure that you can only put letters where letters should be and numbers where numbers should be.

Postcode: CV43 9PB

Telephone number (01926) 615432

 

 

 

Copyright © www.teach-ict.com