Database Relationships  «Prev 

Using Cascade Delete

  1. To start off the simulation, here is the Clients table in datasheet view. The record you will work with is already highlighted. First thing is to see what happens when referential integrity is turned on, without Cascade Delete set to Yes. Press the Delete key.
  2. This is the message received when referential integrity is turned on, without Cascade Delete set to Yes. Now it is time to go set Cascade Delete to Yes. Click OK.
  3. Close the Clients table by clicking the second “x” down from the top right-hand corner.
  4. Click the Tools menu choice.
  5. Now click the Relationships… option in the Tools menu.
  6. Here is the now familiar Relationships Layout window. Double-click the line between the Clients and Projects tables.
  7. Now you can see the Edit Relationships dialog. Click the Cascade Delete Related Records option.
  8. That’s all there is to do for the relationship between Clients and Projects. Click OK.
  9. As you can see here in the Relationships Layout window, you still have to set the Cascade Delete option for the Projects and Hours relationship. Doubleclick the line between the Projects and Hours tables.
  10. Once again you can see the Edit Relationships dialog. Click the Cascade Delete Related Records option.
  11. Click the OK button to accept the change.
  12. Now you are again brought back to the Relationships Layout window. All the changes necessary have been made. Now it’s time to test the changes. Click the second “x” down from the top right-hand corner.
  13. To test the changes made we need to open the Clients table in Datasheet view again. Click the Open button.
  14. Now click the record selector for the record of “Textiles International.” This is the gray button located on the left of the record.
  15. Ok, now is the moment of truth. Press the Delete key and see what happens.
  16. This is the message you will now receive because Cascade Delete is now turned on for all relationships of Clients.