开发者

best way to set up my mysql schema: songs and tags

开发者 https://www.devze.com 2023-03-01 12:05 出处:网络
greetings. I have a table full of songs full of data (artist, songname, link, etc). I want to set up a relationships with tags. In the end, I want to search by tag and return a playlist of relevant s

greetings.

I have a table full of songs full of data (artist, songname, link, etc). I want to set up a relationships with tags. In the end, I want to search by tag and return a playlist of relevant songs.

here is what I was thinking: (rough pseudo code):

TABLE songs(
id开发者_C百科 int(16) primary index,
...
)

TABLE tags (
id int(16) primary index,
...
)

TABLE taggedAs (
songId int(16),
tagId int(16),
songId foreign key songs(id),
tags foreign key tags(id)
)

however these seems sucky because whenever i want to tag I have to do operations on each of the three tables. if I could use something like mongodb (oh i wish), i would just store an array of tagnames on the songs.

also, it'd be nice to have related tags, but I don't know if that is possible with this design.

0

精彩评论

暂无评论...
验证码 换一张
取 消