Moodle has never had foreign keys in its database, because we started in the dark days of MySQL 3.x. It would be really nice if we could enable them. It would detect many bugs, and so make Moodle more robust. However, there are a lot of steps required on the way to achieving that.
|New flag for each install.xml file: Foreign keys are safe
|New option $CFG->foreignkeys = NONE | SAFE | ALL in config.php