My question is say you ran a daycare and had a table for the children and another for their related school (with the FK in the child table), if the school of some of the children, for some reason, closed down, and you had the On Delete option set to SET NULL, would this make sense and also, could you then update the related foreign key to their new school or how would you address this?

  • 1
    Don't delete the data, insert new ones and change the foreign key to the new id,k as long the id exists the db doesn't mind – nbk Jul 25 '20 at 16:37
  • 1
    Please provide SHOW CREATE TABLE for both tables if you want further help. – Rick James Jul 25 '20 at 19:16
  • Thanks nbk. Very helpful. @RickJames, is there somewhere else where novices can ask such questions, as I'm probably a little out of my depth here – zv426 Jul 25 '20 at 23:12
  • Database admin questions belong here; SQL questions (such as yours) belong in stackoverflow.com. Both handle a spectrum of users (newbies to experts). – Rick James Jul 26 '20 at 3:53
  • Thanks for that, noted. – zv426 Jul 26 '20 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.