0

I have researched this on my own but not really sure of the terms I should use and have not gotten far. Basically I'm trying to figure out how to implements tags for a table row. So if my table was musicFile, my tags would be artist, genre, etc.... But lets say some musicFiles would only have artist, or genre so its variable.

I think I would need a separate table for Tags but even then there would have to be foreign keys that are placed in the musicFile table and I end up at the starting point since its 1-1, meaning that its still variable. I would not know at database creation time how many fields to dedicate to Tag foreign keys.

  • think this is my answer stackoverflow.com/a/7094232/530933 – owen gerig Jun 12 '12 at 23:55
  • hi owen, are you looking for a way to implement Tags in your system or you are asking about multiple foreign keys in general, because there are many ways of Tag implementations, there is 1 to 1 or 1 to many or even denormalized in a single table, it all depends on which way you want that fits you. – AmmarR Jun 13 '12 at 6:46
  • i am looking for the proper table format for 1->many, right? one music file to many tag fields? – owen gerig Jun 13 '12 at 16:57
1

If a MusicFile has multiple Artists and an Artist has multiple MusicFiles then yes you need a link table between the two (as per the answer in your comment). However, if, for example, you only ever want to attach a single Genre to any given MusicFile, then you could just have a field for genre inside the MusicFile table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.