Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django foreign key integrity with MyISAM

If MyISAM doesn't have FK integrity, how does a django app that uses MyISAM tables enforce the integrity of the FK constaints?

like image 573
David542 Avatar asked Apr 16 '12 18:04

David542


1 Answers

Poorly. It does its level best to issue updates and deletes when the referant changes, based on information it has already loaded from prior interactions, but there's just nothing protecting your data from becoming inconsistent.

The ForeignKey construct exists less to declare the integrity constraints as it does to tell django how the different tables link together, so you can traverse in python through the attributes to other model instances of other types. The orm-driven cascading is at best a band-aid over the shortcomings of databases like MyISAM. If this is important to you (and it should be), you should migrate away from the MyISAM engine to InnoDB or PostgreSQL.

like image 173
SingleNegationElimination Avatar answered Oct 16 '22 15:10

SingleNegationElimination