TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Things that don’t work well with MySQL’s FOREIGN KEY implementation

75 点作者 grep_it大约 2 年前

6 条评论

wswope大约 2 年前
Just to throw additional warnings on the pile, MySQL FKs are not ANSI SQL compliant and can be set up on non-unique columns, which can be a major pain when porting across DBs.<p><a href="https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;8.0&#x2F;en&#x2F;ansi-diff-foreign-keys.html" rel="nofollow">https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;8.0&#x2F;en&#x2F;ansi-diff-foreign-ke...</a>
评论 #35776200 未加载
评论 #35776589 未加载
Dachande663大约 2 年前
I am probably in the minority and would get shouted at by a DBA of yore, but I use foreign keys for referential integrity and… that’s it. We use soft deletes for almost all rows, so the whole cascading side is less relevant for us than getting an error in test or even production because a missing relation has been used. Combined with using non-integer primary keys, it’s godsend.
评论 #35774395 未加载
评论 #35777180 未加载
评论 #35776392 未加载
ksec大约 2 年前
I will take another rare opportunity of anything MySQL ends up being on HN, Considering [1] mySQL v5.x will EOL this year. And MySQL 8.0 with EOL in 2026. Does anyone knows if MySQL 9.0 will come anytime soon?<p>[1] <a href="https:&#x2F;&#x2F;endoflife.software&#x2F;applications&#x2F;databases&#x2F;mysql" rel="nofollow">https:&#x2F;&#x2F;endoflife.software&#x2F;applications&#x2F;databases&#x2F;mysql</a>
评论 #35778157 未加载
frazerclement大约 2 年前
Nice article.<p>Note that there&#x27;s more than one &#x27;MySQL FOREIGN KEY&#x27; implementation. MySQL Ndb Cluster also supports foreign keys with some differences wrt the InnoDB implementation :<p>- NDB, therefore not limited to a single MySQL Server, shard etc - Not limited to references between tables in a single database - Supports NoAction deferred constraint checks - Cascaded changes Binlogged independently as part of RBR (Nice side effect of reducing replica apply time work) ...<p><a href="https:&#x2F;&#x2F;dev.mysql.com&#x2F;blog-archive&#x2F;foreign-keys-in-mysql-cluster&#x2F;" rel="nofollow">https:&#x2F;&#x2F;dev.mysql.com&#x2F;blog-archive&#x2F;foreign-keys-in-mysql-clu...</a><p>Some of the issues described wrt DDL limitations are shared.<p>Many schemas seem to overuse foreign keys perhaps under the assumption that they are required for or accelerate joins?
评论 #35781536 未加载
ComputerGuru大约 2 年前
The last time I checked, MySQL still can’t do foreign keys with binary blobs. (I think it works with some very specific limitations but not enough to actually use in the real world.)
评论 #35777594 未加载
pjungwir大约 2 年前
It was interesting to hear this aside about the MySQL roadmap:<p>&gt; MySQL is pushing towards INSTANT DDL<p>When I need MySQL these days I automatically go for MariaDB instead, but I guess they are going to diverge more and more. Does anyone more involved in the MySQL&#x2F;MariaDB world have any thoughts about how they choose and the future of those two projects?