2008年10月17日星期五

Re: [fw-db] Re: Re: Re[fw-db] ferencemap: delete CASCADE

I would rather see cascading operations removed from Zend_Db completely.  It's not safe to implement cascading operations in client code, because it introduces race conditions.  That is, concurrent updates by other clients can interrupt a cascading operation, which can cause broken data integrity.

I agree. While it's kinda neat to have this feature available in client-side code, it is *much* better to have the database handle this. 

On Fri, Oct 17, 2008 at 10:19 AM, Bill Karwin <bill@karwin.com> wrote:

On Oct 17, 2008, at 9:31 AM, EducatedFool wrote:

Let's say I switch my db to InnoDB. What 'll it return when I try to delete
a parent row when it exists in a child row? Just 'false'?

It gives this error:

"ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails" 

Can someone say why I just have to keep with MyISAM? Why is that better?

In some scenarios MyISAM is faster than InnoDB, and MyISAM supports FULLTEXT indexes.  However, MyISAM does not support transactions or foreign keys.

About cascade delete: In my opinion the framework needs to folow the
reference map through all the levels. Don't see why it wouldn't...:-)

I would rather see cascading operations removed from Zend_Db completely.  It's not safe to implement cascading operations in client code, because it introduces race conditions.  That is, concurrent updates by other clients can interrupt a cascading operation, which can cause broken data integrity.

Regards,
Bill Karwin



--
-Hector

没有评论: