Home arrow PHP arrow Performing Record Updates with Foreign Key Constraints in MySQL

Performing Record Updates with Foreign Key Constraints in MySQL

In this fourth installment of a six-part series, I explain how to use foreign key constraints to update rows of two InnoDB tables via a basic abstraction class built into PHP 5. This example will help you start utilizing foreign key constraints with a particular server-side scripting language.

TABLE OF CONTENTS:
  1. Performing Record Updates with Foreign Key Constraints in MySQL
  2. Review: updating and deleting database rows in cascade
  3. Updating database records in cascade with PHP 5
  4. The MySQL abstraction class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
December 17, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Being the most popular open source RDBMS available nowadays, itís not breaking news to say that MySQL supports multiple storage engines, including the default, highly-fast MyISAM type, which you may have used hundreds of times before for developing your own database-driven web applications.

However, there are times when itís necessary to look at other MySQL storage engines. Sometimes a particular project needs to implement additional features, like handling foreign key constraints. In a case like this, InnoDB tables will fit this requirement very efficiently, even though they may be a bit slower in terms of performance than their MyISAM counterparts.

Undeniably, one of the major advantages to using foreign key constraints with InnoDB tables is that this capability allows you to handle and maintain relationships between several tables at the database level, instead of delegating this task to certain modules or libraries of the application responsible for interacting with the tables in question.

Naturally, if youíve been a patient follower of this series of articles and already went through all of the articles that precede this one, then you have a solid background in working with foreign key constraints within IndoDB tables. In those tutorials I explained how to trigger cascading updates and deletions on the records of a child table, when performing the same operations on rows of its related parent table.

Those basic tables initially comprised the data layer of a fictional blog application, but as you might have guessed, foreign key constraints can be used in a variety of programs with great results. In addition, itís valid to recall that all of the examples developed so far were coded by utilizing raw SQL, without tying them to a particular programming language.

Taking into account that MySQL is very often strongly coupled with PHP, in this fourth part of the series Iím going to demonstrate how to work with foreign key constraints within a pair of InnoDB tables that will be accessed with PHP 5. Doing so should give you an accurate idea of how to use this feature in a more realistic scenario.

Now itís time to leave the preliminaries behind and learn how to leverage the power of foreign key constraints with PHP 5. Letís get started!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- 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: