List:General Discussion« Previous MessageNext Message »
From:Ian Simpson Date:January 2 2009 11:14am
Subject:Re: How to Use Cascade Delete Properly
View as plain text  
That looks ok to me; I seem to have misremembered the RESTRICT keyword
as CONSTRAIN, since it's been a while since I've had to use it.

Bear in mind that I don't think MySQL has a check to make sure that the
same foreign key does not already exist; I have seen a table that had
the same foreign key three times. You should be ok as you are specifying
a name for the constraint, and it checks for unique names. 

On Fri, 2009-01-02 at 06:03 -0500, Lola J. Lee Beno wrote:
> Ian Simpson wrote:
> > If you want deletes to be blocked, then you shouldn't be using ON DELETE
> > CASCADE; the default behaviour is ON DELETE CONSTRAIN, which seems to be
> > what you want; it will refuse to delete any rows that are depended on by
> > rows in other tables.
> >   
> Wouldn't that be:
> ALTER TABLE `jobsearchtwodb`.`jobposts` ADD CONSTRAINT `adsourcefk` 
> FOREIGN KEY `adsourcefk` (`adsource_id`)
>     REFERENCES `adsource` (`adsource_id`)
> ON DELETE RESTRICT having the behavior like ON DELETE CONSTRAIN?
> -- 
> Lola J. Lee Beno - ColdFusion Programmer/Web Designer for Hire
> | Blog at
> "No greater injury can be done to any youth than to let him feel that
> because he belongs to this or that race he will be advanced in life 
> regardless of his own merits or efforts." - Booker T. Washington
Ian Simpson
System Administrator

How to Use Cascade Delete ProperlyLola J. Lee Beno1 Jan
  • Re: How to Use Cascade Delete ProperlyIan Simpson2 Jan
    • Re: How to Use Cascade Delete ProperlyLola J. Lee Beno2 Jan
      • Re: How to Use Cascade Delete ProperlyIan Simpson2 Jan
  • RE: How to Use Cascade Delete ProperlyJerry Schwartz2 Jan
    • RE: How to Use Cascade Delete ProperlyMartin Gainty3 Jan