The rule ensures thatthe only data that can be entered
TASK must exist in the list that contains “Mr”, “Mrs”, “Miss” O CD 9.10 Sales processing 3.mdb and “Dr”. It is a lookup in list method of validation. Open CD 9.10 Sales processing 3.mdb 1 Open the order table and add Sales Rep IDs 4, 5, 8, 11 and 15 to the records. a Which ones worked? TASK b Which ones did not work? O CD 9.11 Sales proeessingvatidation.mdb c Why didn’t they work? Open CD 9.11 Sales processingvalidation.mdb and open 2 Try to create a relationship between Product and the table Employee. Category and enforce referential integrity. 1 Create a validation rule that will only allow the entry a What happens? of "UK” or “USA” for the Country. b Why has this happened? 2 Create an appropriate error message. c Correct any data that is causing this problem and try to create the relationship again. There area variety of validation rules that can be used within a database including: Validate and verify data • lookup in list (by looking up in a list entered within the rule) Validation rules • lookup in list (by using referential integrity) The principal of validation was introduced in Chapter 1. • lookup in list (by using a lookup table) Database management systems can apply validation rules to data that is input. If data passes the validation rules, then • range they will be accepted. If data fail the validation rules, then • data type they will be rejected and an error message may be shown. • format 149 • length • presence.
In this database, the user is attempting to enter the
title that a Sates Rep will be addressed by. They have four valid options - “Mr”, “Mrs”, “Miss” or “Dr”. Type Field Rule The user has accidentally entered “Msr” which is Lookup in list Gender ”M"or“F” not a valid option. An error message has appeared Lookup in list Title IN (“Mr”, “Mrs”, telling the user what to do to fix the problem. "Miss", “Dr”) In this database, the user is attempting to enter the Range Date of Birth >DATE() (must be title that a Sales Rep will be addressed by. They after today's date) have four valid options - “Mr”, “Mrs”, “Miss” or “Dr”. Range Date Joined >28/02/1995 The user has accidentally entered “Msr” which is Range Reorder Between 1and not a valid option. An error message has appeared Amount 2000 telling the user what to do to fix the problem. Range Reorder >0 » Employee ID • Click to Add - Level 1Davollo Nancy Sales Representative 2 Fuller 3 leverling Andrew Janet vice President, Sales Sales Representative Microsoft Access Data Type State Like "[A-Z][A-Z]” Margaret Sales Representative is m,‘ (must be two text Steven Sales Manager Michael Sales Representative characters) _ Figure 9.22 - Error message. Format Email Like “*@*.*” (* means This is the rule that had been set up: Address any character) Validation rule InCMr’, 'Mrs', 'Miss', 'Dr') Length Colour Like “??” (must be Validation text Title must be Mr, Mrs, Miss or Dr two characters) Figure 9.23 - Validation rule. Presence Forename IS NOT NULL