[nycphp-talk] MySQL, MyISAM tables, <trigger> | <on delete cascade> - Help
David Mintz
dmintz at davidmintz.org
Fri Feb 20 10:22:04 EST 2004
MyIsam doesn't support foreign key constraints but InnoDB does. If you use
InnoDB tables you can have cascading deletes.
Alternatively, tho you said you want to avoid it, you can do it yourself
in the middle tier (PHP) -- it ain't that hard.
See, e.g., "MySQL" by Paul DuBois, 2nd edition.
On Fri, 20 Feb 2004, Phil Powell wrote:
> I am having to create a cascade delete effect on table "department" that
> is configured in the following fashion:
>
> I am having to delete a department; if I do so, I would naturally have
> to delete all child records associated with the department.
> Best approach would be to do a "cascade delete" variation (deleting all
> child records first and then parent row), however, only
> MaxDB seems to support that (see
> http://www.mysql.com/documentation/maxdb/94/c38409c20611d5993d00508b6b8b11/content.htm
> and
> http://www.mysql.com/doc/en/InnoDB_foreign_key_constraints.html ),
> however, that seems to be not possible since my tables are MyISAM
> by default. Therefore, I am offered the possibility of a trigger.
> However, the beforementioned article indicates triggers
> aren't supported in MySQL.
>
> What would then be your best recommendation, based upon the need and the
> schema, for me to ensure that all related records are
> deleted? I would prefer not to have to write a PHP script to have to do
> so, but is that all I'm stuck with?
---
David Mintz
http://davidmintz.org/
"Anybody else got a problem with Webistics?" -- Sopranos 24:17
More information about the talk
mailing list