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.

TABLE OF CONTENTS:
  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
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap

Dev Shed Tutorial Topics: