Re: deleting a row potentially referenced by many rows in another table

From: cm <cmonthenet_at_yahoo.com>
Date: Tue, 29 Sep 2009 12:31:10 -0700 (PDT)
Message-ID: <70fc8df7-c197-44e6-ba14-9eb84ff10614_at_33g2000vbe.googlegroups.com>



>
> Yeah, off-hand all that comes to mind is a trigger that fires on
> DELETEs and does an EXISTS test. Since your PK and, almost certainly,
> FK columns are indexed, the performance may be acceptable. Which RDBMS
> are you running?
>
> --Jeff

I am running MySQL. Yes, the trigger approach was suggested to me separately, and probably could be made to work. I am wondering about concurrency issues though. Suppose the EXISTS test indicates that no FKs reference the applicable parent row when the check is made, but, before the delete of the parent row can be made, another insert finds the parent row already exists and references it.

Thanks,
Carl Received on Tue Sep 29 2009 - 14:31:10 CDT

Original text of this message