[development] Foreign keys in Drupal 6

Chad Phillips -- Apartment Lines chad at apartmentlines.com
Mon Jun 4 14:00:31 UTC 2007

> On 04 Jun 2007, at 05:14, David Strauss wrote:
>> Assuming the foreign keys patch to the schema API makes it in,  
>> there are
>> four ways we can approach foreign keys in Drupal 6.
>> 1. Don't use them at all. Just provide the schema API for contrib
>> modules with higher database requirements than core.
>> 2. Configure foreign keys as RESTRICT on delete. This will have no
>> effect on MyISAM, but it will improve code quality because operations
>> creating inconsistency would fail. Such operations would then be
>> rewritten to manipulate the database in a consistent way.
>> 3. Configure foreign keys as CASCADE on delete and have extra PHP run
>> whenever a query manipulates a database using MyISAM. Basically,
>> whenever a DELETE query gets sent to a MyISAM system, we would  
>> convert
>> it to a SELECT query to identify the rows that would be deleted.  
>> Then,
>> we would delete the records attached with foreign keys. Finally, we
>> would run the original DELETE query. This would have to be recursive.
>> 4. Configure foreign keys as CASCADE on delete and have modules
>> conditionally run queries in their deletion hooks depending on the
>> storage engine. If a module doesn't check the storage engine type,  
>> the
>> DELETE it runs would simply be redundant.

#2 also seems like the most sensible to me for Drupal 6.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20070604/e396f9e8/attachment.htm 

More information about the development mailing list