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
> ON UPDATE NO ACTION;
> ON DELETE RESTRICT having the behavior like ON DELETE CONSTRAIN?
> Lola J. Lee Beno - ColdFusion Programmer/Web Designer for Hire
> http://www.lolajl.net/resume | Blog at http://www.lolajl.net/blog/
> "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