Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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.

share|improve this question
    
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 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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