为什么 CMS 数据库(例如 WP 和 PRESTASHOP)不在其表上使用外键?我认为表应该有外键以防止孤立行。
最佳答案
摘自
的帖子(显然是WP工作人员)
wordpress.org
WordPress › Support » Plugins and Hacks » Hacks
The problem with MySQL is that only a few installations default to innodb. Most use MyISAM tables because they are more "beginner friendly".
Because of this WordPress, and pretty much every other PHP-based CMS that I've seen out there, has to think that it will be using the lowest common denominator, so MyISAM tables with no references are required so it can be as universal as possible.
I will add that the WP system has been set up to use the PHP code to enforce the integrity where it can. That's why it's always best to use the built-in WordPress functions rather then trying to roll your own.
只有 MySQL InnoDB 存储引擎强制执行外键声明。但它们被 MyISAM 存储引擎视为注释,所以我不知道为什么它们没有被声明。
“定制 Prestashop 软件解决方案以及共享和专用虚拟托管服务”成员的帖子
prestashop.com Forum > Technical Forum > Adapting my PrestaShop > Development
Because it is only supported when using InnoDB, and not everyone uses that.
And btw, backwards compatibility and thorough testing is not something that Prestashop is famous for.
关于mysql - 为什么 CMS 数据库不使用外键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33139033/