Django foreign key integrity with MyISAM
Asked Answered
G

1

5

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

Gantlet answered 16/4, 2012 at 18:13 Comment(0)
M
10

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.

Mclendon answered 16/4, 2012 at 18:44 Comment(1)
Agree. Also you now have no integrity check at the db level. So if anyone has access to the db and changes things, django is no longer involved.Mandamus

© 2022 - 2024 — McMap. All rights reserved.