TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

75 pointsby grep_itabout 2 years ago

6 comments

wswopeabout 2 years ago
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 未加载
Dachande663about 2 years ago
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 未加载
ksecabout 2 years ago
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 未加载
frazerclementabout 2 years ago
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 未加载
ComputerGuruabout 2 years ago
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 未加载
pjungwirabout 2 years ago
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?