In https://github.com/meisterT/domjudge/blob/d5e1091988d21c767fb9a68494580ef715bac059/webapp/src/Controller/BaseController.php#L231-L236 we have special code to handle cascading deletes from problem into internal_error. It would be cleaner if we'd change the internal_error table to have an explicit column problemid with a cascading delete foreign key defined on it. And similar for other tables like language.
Note that we should be aware of #243.