[development] Foreign keys in Drupal 6
karoly at negyesi.net
Mon Jun 4 04:03:18 UTC 2007
----- Start Original Message -----
Sent: Sun, 03 Jun 2007 22:14:53 -0500
From: David Strauss <david at fourkitchens.com>
To: development at drupal.org
Subject: [development] Foreign keys in Drupal 6
> 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.
I do not even consider this an option.
> 2. Configure foreign keys as RESTRICT on delete. This will have no
> 3. Configure foreign keys as CASCADE on delete and have extra PHP run
OK, someone else will probably need to translate this to layman terms. But here is the thing: if we add PK support then we have a graph (DAG, actually) where the vertices are the tables and the edges are the PK relationships. In order to properly simulate RESTRICT you need to topologically sort this DAG so at any time you only delete tables that have no outgoing edges. At this point you have simulated CASCADE as well... I have the supporting code (top.sort) for this in my sandbox, originally written to replace module.weight hence the name weights.php .
More information about the development