如何来模拟&QUOT的概念;拥有" (例如,当一个艺术家"功能"上一首歌曲) [英] How to model the concept of "Featuring" (i.e., when an artist is "featured" on a song)

查看:140
本文介绍了如何来模拟&QUOT的概念;拥有" (例如,当一个艺术家"功能"上一首歌曲)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时不止一个艺术家将在一首歌曲。例如,Jay-Z的新歌一个明星的诞生特色艺术家科尔,因此可以被列为 - 在目录JAY-Z(特色科尔)一个明星的诞生。我的问题是如何塑造这个在我的数据库。

Sometimes more than one artist will be on a song. For example, Jay-z's new song "A Star is Born" features the artist Cole, and thus would be listed as "Jay-z (featuring Cole) - A Star is Born" in a catalog. My question is how to model this in my database.

现在它是pretty的简单:每首歌曲 belongs_to的:艺术家和每一位艺术家的has_many:歌曲。我想改变这个让歌曲有很多艺术家,并指定为主一位艺术家 - 也就是说,如果A,B和C都与一个特定的歌曲相关联,一个是主要的,这首歌的歌手会显示为A(配有B和C)。

Right now it's pretty simple: every song belongs_to :artist and every artist has_many :songs. I want to change this so that songs have many artists, with one artist specified as "primary" -- i.e., if A, B, and C are all associated with a given song and A is primary, the artist of that song will be displayed as "A (featuring B and C)".

下面是我在想什么:

歌曲:

has_many :artists, :through => :performances

歌手:

has_many :songs, :through => :performances

其中性能模式将对主单场?,指定是否给定的性能获得了初级表现的歌曲,这意味着与性能相关的艺术家的歌曲的主要艺术家。

where the performance model would have a single field for primary?, designating whether a given performance was the "primary" performance on the song, meaning that the artist associated with that performance is the primary artist on the song.

请问这种做法是否合理?

Does this approach make sense?

推荐答案

是的。你钉它。

这篇关于如何来模拟&QUOT的概念;拥有" (例如,当一个艺术家"功能"上一首歌曲)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆