Home arrow PHP arrow Triggering Cascading Updates and Deletions with Foreign Key Constraints

Triggering Cascading Updates and Deletions with Foreign Key Constraints

Welcome to the final installment of a series on working with foreign key constraints in MySQL. With a respectable number of code samples, this series walks you through the basics of using foreign key constraints in MySQL tables and teaches you how to use them specifically for maintaining the integrity of relational databases.

  1. Triggering Cascading Updates and Deletions with Foreign Key Constraints
  2. Review: cascading updates with MySQL InnoDB tables
  3. Redefining the previous InnoDB tables
  4. Updating and deleting records in cascade within the same MySQL table
By: Alejandro Gervasio
Rating: starstarstarstarstar / 1
December 23, 2009

print this article



And now that you've been introduced to the goal of this group of articles, itís time to refresh the topics that were covered in the last tutorial. In the penultimate part of the series, I showed you how to trigger the deletion in cascade of rows of a child MySQL table after performing the same operation on the records of its corresponding parent table.

In this example, the tables that I utilized to demonstrate how useful foreign key constraints can be comprised the database schema of a fictional blog program.  It allowed some hypothetical users to post comments on a specific blog entry. Of course, the most relevant detail to stress here is that the cascading deletion of comments was triggered and handled internally by MySQL, in this way allowing you to implement a much simpler logic within the blog application.

Nevertheless, foreign key constraints allow you to handle both updates and deletions in the same MySQL table with the same ease, so in this final chapter of the series Iím going to explain how to achieve this by using the sample MySQL abstraction class coded in the preceding tutorial.

So, are ready to tackle the last chapter of this series on working with foreign key constraints in MySQL? Then start reading now!

>>> More PHP Articles          >>> More By Alejandro Gervasio

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: