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.
Personally, I think #2 would be a great first step. We could then consider #3 or #4 for Drupal 7. -- Dries Buytaert :: http://www.buytaert.net/