Contents
Lesson 4: Pet sitters
In this lesson, you will learn about the importance of validation rules in ensuring your database contains high quality, usable data, and you’ll connect two tables using a relationship to make a relational database.
Learning objectives
- Understand the term validation
- Learn about different forms of validation
- Understand the importance of validation in data gathering
- Build a table from scratch, including validation rules
Types of validation check
Rule | Description |
---|---|
Presence check | A field with a presence check cannot be left blank. In Access, this is achieved by ticking Required in field properties. |
Type check | A type check prevents input of data in incorrect types, e.g. not allowing letters to be typed into a number field. |
Length check | A length check can prevent data that is longer than the maximum limit from being entered, e.g. allowing up to 15 characters for a First Name field. |
Range check | A range check can be applied to any numerical data (numbers/currencies/dates) to prevent data outside the range from being entered, e.g. Number in stock in a shop database must be between 0 and 50. |
Input mask | Dictates the format of what can be typed in. This is useful for telephone numbers by adding structure: (000) 000-0000. |
Is it valid?
Input masks
Input masks are really helpful when data needs to have a specific format, like a telephone number: (0986) 555-1495 or a registration number: G59 6APW. Using the table below as a guide, type out the input masks for the questions that follow.
Character | Description |
---|---|
0 | Enter a digit (0 to 9). |
9 | Enter an optional digit (0 to 9). |
L | Enter a letter. |
A | Enter a letter or a digit. |
> | Convert all letters to uppercase. |
< | Convert all letters to lowercase. |
Using this information as a guide, let’s look at input masks for the examples above. The telephone number (0986) 555-1495 would have the input mask (0000) 000-0000. The postal code G59 6APW would have the input mask L00 0LLL.
Task: Pet Sitters
Download pet-sitters.accdb and save it into your Z:/ drive. Take a look at the two tables in the database and answer the questions below to get familiar with the data set.
- Open tbl_Customer and go in to Design View.
- We’re going to add some validation rules to this table to reduce errors.
- Set the Field Size of First Name, Last Name and Pet Name to 15.
- Add an input mask to the Phone field to only accept three numbers, a dash and four numbers, e.g. 555-1234.
- We only accept pets aged between 2 and 15. Add a range check to the validation rule for the Pet Age field.
- Leave design view and save the table.
Find out how
- Open tbl_Sitter and go in to Design View.
- Reduce the field size of Sitter ID to 2 and apply an input mask that requires 2 letters.
- Add a range check to the Zip field that only accepts values between 12800 and 12999.
- Leave design view and save the table.
- We have just recruited two new sitters to fill our vacancies. Add their details to the database:


- In tbl_Customer, Gerry Trent’s cat Missy can now be assigned a sitter. Check who is available in her town to look after cats and type the correct sitter ID in.
Making a relationship
- We now have two tables of data that can be linked by building a relationship. Create a one-to-many relationship between tbl_Sitters and tbl_Customers using the Sitter ID field.
Find out how
Input form
- If we’re going to add data to a database, it’s helpful to make an input form. This shows only one record at a time and makes it much easier for a user to add data without making mistakes. Include this logo.
- Create a form (called frm_Customer) based on tbl_Customer.
Find out how
- Add the following records to your database using the input form you just made.
1 | 2 | 3 | |
---|---|---|---|
Customer ID | P04 | P05 | W04 |
First Name | Laurena | Dan | Phylis |
Last Name | Cadigan | Charles | Gee |
Street | 258 Prairie St. | 9 Summer Rd. | 49 Crescent Ave. |
City | Pleasantview | Pleasantview | Willow Creek |
Phone | 555-8845 | 555-4721 | 555-7031 |
Pet Type | Dog | Dog | Cat |
Pet Name | Milo | Sasha | Tucker |
Pet Age | 11 | 8 | 13 |
- Download the waiting list file (sitterswaitinglist.csv) and append them to the bottom of your tbl_Customer table.
Find out how
- Using the table below, use filters in the tbl_Customer table to assign the correct sitter for each pet who doesn’t yet have one.
Find out how
Sitter ID | City | Dogs | Cats |
---|---|---|---|
AK | Pleasantview | ✔ | |
CR | Three Lakes | ✔ | ✔ |
JL | Willow Creek | ✔ | |
RG | Pleasantview | ✔ | |
SL | Willow Creek | ✔ |
Consolidation & practice