I was adding a "Watches" table to my database today to allow Users to track certain (lets just call them) Items in the database. Basically, when the Item is updated, send a email to the user to let them know. Pretty simple.
Items-1:M->Watches<-M:1-Users
I straightforward M:N relationship. I checked "Cascade Update and Delete" for both tables, but got an error I've never seen before.
Introducing FOREIGN KEY constraint blah_blah on table Items may
cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or
ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Huh?
I talked with Bill Pierce a bit, and he was wondering about the "Cycle" in the word. He said it sounded like a table was linked someplace else so that if you deleted an item it was also trying to delete Watches and then Users.
Sure enough after looking, another table came into play: Companies. A company could have many Users and could also have many Models. Sure enough that was my problem. Luckily for me, a company was not ever going to be deleted from the database (at least, from the program) so I could turn off the Cascade options for that table.
I set the cascade delete and update on the Watches table and no more error! Another disaster averted...