<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV><BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">On 04 Jun 2007, at 05:14, David Strauss wrote:</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; min-height: 17.0px"><BR></P> <BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">Assuming the foreign keys patch to the schema API makes it in, there are</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">four ways we can approach foreign keys in Drupal 6.</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px; font: 14.0px Helvetica; min-height: 17.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">1. Don't use them at all. Just provide the schema API for contrib</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">modules with higher database requirements than core.</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px; font: 14.0px Helvetica; min-height: 17.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">2. Configure foreign keys as RESTRICT on delete. This will have no</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">effect on MyISAM, but it will improve code quality because operations</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">creating inconsistency would fail. Such operations would then be</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">rewritten to manipulate the database in a consistent way.</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px; font: 14.0px Helvetica; min-height: 17.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">3. Configure foreign keys as CASCADE on delete and have extra PHP run</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">whenever a query manipulates a database using MyISAM. Basically,</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">whenever a DELETE query gets sent to a MyISAM system, we would convert</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">it to a SELECT query to identify the rows that would be deleted. Then,</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">we would delete the records attached with foreign keys. Finally, we</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">would run the original DELETE query. This would have to be recursive.</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px; font: 14.0px Helvetica; min-height: 17.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">4. Configure foreign keys as CASCADE on delete and have modules</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">conditionally run queries in their deletion hooks depending on the</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">storage engine. If a module doesn't check the storage engine type, the</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 10.0px"><FONT face="Helvetica" size="4" style="font: 14.0px Helvetica">DELETE it runs would simply be redundant.</FONT></P> </BLOCKQUOTE></BLOCKQUOTE><BR></DIV><DIV>#2 also seems like the most sensible to me for Drupal 6.</DIV><BR></BODY></HTML>