Alright, my brain is having a bit of trouble wrapping around the solution to a problem I have. I can think of several solutions, but they all seem like horrible hacks and aren't elegant in the slightest.
I'm working on a website for a publishing house. I'll be storing books in a MySQL database, with all of the information (title, author, isbn, price, publication date, description, etc, etc, etc). The issue is how I will be categorizing these books by genre.
I have many different genres. Books can belong to one or more genres. So for example, a book might be both 'Biography' and 'Non-Fiction'. Or, perhaps 'Crime' and 'Fiction' and 'Translated Fiction', or 'Crime' and 'Biography' and 'Non-Fiction'. Or maybe just 'Travel.' You get the idea. We haven't quite settled on the exact genres yet, but it is clear from the available titles that there will be books that fall into more than one category.
I've decided that on the page where you enter the information, the user will be able to use checkboxes to pick as many of these genres as they like for a book. My trouble is how to store it in the database. I considered having a bunch of fields in the book table (one for each genre) and setting them or unsetting them as neccesary (this would make it easy to insert, and not too bad to display). Alternatively, I could have one field, and comma-separate the genres (this would make them easy to display, but slightly ugly to edit).
How would you store this information?