mysql - 为什么 CMS 数据库不使用外键?

标签 mysql database content-management-system foreign-keys relational-database

为什么 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/

相关文章:

php - 从 php <select> 从数据库中删除

mysql - HQL/MySQL 用于列出不同项和重复项

mysql - 合并行并给我总计数

Python - 从多个对象访问单个数据库包装对象

sql - JdbcTemplate动态表名和SQL注入(inject)

python - 在 Django 支持的网站上托管 WordPress 等外部 CMS

iphone - 在 iOS 应用程序中使用 wordpress 用户帐户

java - 在alfresco插件代码和ImageMagick中尝试各种方式将cmyk转换为rgb,但无法完成。请检查我的发现,请给我建议

mysql - GROUP BY 和 Mysql 5.7 - 错误分组

mysql - 在其他服务器上恢复mysqldump不会恢复密码