Description

Independent Project 2-5

Life’s Animal Shelter wants to expand the database created in the Independent Project 1-5 . To ensure consistency, the starting file is provided for you. In this project, you use Design view to create a second table, edit field properties, integrate data integrity rules, and enter data. You also create a relationship between the two tables and enforce referential integrity constraints. Finally, you add data using the relationship between tables.

[Student Learning Outcomes 2.1, 2.2, 2.3, 2.4, 2.6]

File Needed: LifesAnimalShelter-02.accdb (Available from the Start File link.)

Completed Project File Name: [First Name.Last Name]-LifesAnimalShelter-02.accdb

Skills Covered in This Project

  • Create a table using Design view.
  • Add fields into a table.
  • Edit field properties in Design view.
  • Create an input mask.
  • Create a validation rule and validation text.
  • Save a table.
  • Enter records.
  • Create a foreign key.
  • Create a 1:M relationship between tables.
  • Enforce referential integrity.
  • View a table in Datasheet view and expand related records.
REQUIRED:
  1. Open the LifesAnimalShelter-02 database file.
  2. The file will be renamed automatically to include your name. Change the project file name if directed to do so by your instructor, and save it.
  3. Enable content in the security warning.
  4. Create a new table using Table Design.
    1. Add the fields in Table 2-29 into the table and set field properties.

      Table 2-29

      Field Name Data Type Description Field Size
      OwnerID Short Text Unique owner ID 4
      OwnerLastName Short Text Last name 20
      OwnerFirstName Short Text First name 20
      Address Short Text Street address 40
      City Short Text 20
      State Short Text 2
      ZIP Short Text ZIP Code 5
      Phone Short Text Contact phone number 10
    2. Set OwnerID as the primary key.
    3. Select the State field and type TX in the Default Value.
    4. Save the table as Owners.
  5. Create an input mask for the Phone field.
    1. Select the Phone field.
    2. Use the Phone Number Input Mask.
    3. Don’t make any changes to the mask or placeholder character and select the Without the symbols in the mask, like this radio button.
    4. Finish the Input Mask Wizard.
    5. Save the table.
  6. Create and test a field validation rule.
    1. Select the OwnerID field.
    2. Type Like "#### in the Validation Rule.
    3. Type You must enter a 4-digit Owner ID as Validation Text.
    4. Save the table and switch to Datasheet view.
    5. Test the rule by typing 11 in the first row of the OwnerID column.
    6. Move to the OwnerLastName field. The message box should display the validation text message (Figure 2-92) since the OwnerID is not four digits long.
      Datasheet view of Owners table. Message box contains “You must enter a 4-digit Owner ID” and clickable OK and Help buttons.
      Figure 2-92 Field validation rule error message
    7. Click OK to acknowledge the error.
    8. Delete the contents and type 1111 into the OwnerID field.
    9. Verify that you successfully move to the OwnerLastName field since 1111 meets the validation rule criteria.
    10. Delete this test data record.
  7. Enter the records in Table 2-30 into the Owners table. Life’s Animal Shelter doesn’t have any data about the owners stored electronically so you are unable to import any data. Since the State field has a default value of TX, you can simply accept that value and tab to the next field.

    Table 2-30

    OwnerID OwnerLast Name OwnerFirst Name Address City State ZIP Phone
    0100 Smith Albert 11 Lakewood Drive Abilene TX 79601 325-614-9333
    0101 Weston Mark 2601 Nonesuch Road Abilene TX 79606 325-555-1112
    0102 Rivera Angela 2548 Laney Road Denton TX 76208 940-321-8020
    0103 Moyer Silvia 6867 Anglebluff Circle Dallas TX 75248 972-380-6188
    0104 Wills Mason 2421 Klondike Drive Dallas TX 75228 214-224-5555
  8. Save and close the table.
  9. Determine the foreign key field. Currently, a field is not common across the Owners and Pets tables. A one-to-many relationship exists between the two tables since an owner could adopt many pets, but each pet is only adopted by one owner. The foreign key comes by taking the primary key field from the 1 table and adding it in as an additional field in the M table.
    1. Open the Pets table in Design view.
    2. Add the foreign key field below the Details field using the information in Table 2-31.

      Table 2-31

      Field Name Data Type Description Field Size
      FKOwnerID Short Text Must match an OwnerID in the Owners table 4
    3. Save and close the Pets table.
  10. Create a one-to-many relationship between the Owners and Pets tables.
    1. Open the Relationships window and add the two tables.
    2. Enlarge the table objects, if needed, to see all of the fields.
    3. Drag the OwnerID field from the Owners table on top of the FKOwnerID field in the Pets table. Release the pointer. The Edit Relationships dialog box displays.
    4. Select the choices to Enforce Referential Integrity and Cascade Update Related Fields.
    5. Leave the Cascade Delete Related Records check box not selected. The shelter does not want to delete pet records when it deletes information about an owner.
    6. Create the relationship.
    7. Save the changes and close the Relationships window.
  11. Enter the following data into the specified records in the Pets table to reflect which pets have been adopted:
    1. Open the Pets table in Datasheet view.
    2. Type 0100 in the FKOwnerID field for PetID 1.
    3. Type 0103 in the FKOwnerID field for PetID 3.
    4. Type 0100 in the FKOwnerID field for PetID 12.
    5. Type 0104 in the FKOwnerID field for PetID 14.
    6. Close the Pets table.
  12. View the related data records in the Owners table.
    1. Open the Owners table in Datasheet view.
    2. Click the plus sign to the left of the OwnerID field for Albert Smith, OwnerID 0100. You should see the two pets adopted by Albert.
    3. Close the Owners table.
  13. Close the database.
  14. Upload and save your project file.
  15. Submit project for grading.