首先命名多对多关系哪个表?

发布于 2024-10-27 01:39:31 字数 707 浏览 0 评论 0原文

我读过这个:https://stackoverflow。 com/questions/631850/how-do-you-name-your-many-to-many-relationship-tables 但我的问题有点不同。

我只是想知道如何知道多对多关系中的表名应该首先命名哪个表。在我的关系中,我有 artist_song。一位艺术家可以唱很多首歌,一首歌可以由很多艺术家演唱,但我如何知道是否将其命名为artist_song还是song_artist?虽然我认为这没有什么区别,但是首先命名哪个表有一定的规则可循吗?就我而言,我首先使用艺术家,因为更常见的是一位艺术家可以拥有多首歌曲。一首歌被多名艺人演唱的情况更加罕见。

在这篇文章中: MySQL:如何存储/检索艺术家信息?他们使用 song_artist 来代替,但是用其他方式命名不是更有意义吗?或者这真的不重要,只是一种偏好。我还听说有人只是按字母顺序排列它们。

I've read this: https://stackoverflow.com/questions/631850/how-do-you-name-your-many-to-many-relationship-tables
But my question is a little different.

I'm just wondering how to know which table should be named first for the table name in a many to many relationship. In my relationship, I have artist_song. One artist can sing many songs and one song can be sung by many artists, but how to do I know whether to name it artist_song vs song_artist? Although I don't think this makes a difference, but is there a certain rule to follow for which table is named first? In my case, I used artist first, because it's more often that one artist can have many songs. It'll be more rare that one song is sung by many artists.

In this post: MySQL: How to store/retrieve artist information? they use song_artist instead, but wouldn't it make more sense naming it the other way? Or does it really not matter and is just a preference. I also heard of people just placing them in alphabetical order.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫性小仙女 2024-11-03 01:39:31

我认为这并不重要——因为它是多对多的,所以没有一致的方法来指示哪个是“所有者”。但我建议不要只选择“感觉”正确的一种,而是坚持一种定义的方式,并在组织的风格推荐文档中注明它。

按字母顺序排列效果很好,因为它简单、众所周知,并且具有帮助那些试图查找表格并了解所涉及的两个参与者的人的优点。

I don't think it matters -- since it's many-to-many, there's not a consistent way to indicate which is the "owner". But instead of just going with whichever one "feels" right, I'd recommend just sticking to a defined way and just noting it in your org's style recommendations doc.

Alphabetical works great because it's simple, well-known, and has the advantage of aiding a person who is trying to look up the table and knows the two actors involved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文