Reputation: 49077
I made a question yesterday about this, but I did some changes in my structure.
I have one table containing the questions(foreign key to the category ID). One table containing the categories and one table containing the answers with foreign key to the question table(and primary key which is the answer ID together with the foreign ID).
But my question is, how do I structure my database when one question belongs to multiple categories?
Thanks in advance!
Upvotes: 0
Views: 172
Reputation: 6570
See What is the most efficient way to store tags in a database?
Upvotes: 0
Reputation: 754508
In that case, you need a "link" table between questions and categories - something like:
Question_Categories
QuestionID (FK into table Questions)
CategoryID (FK into table Category)
Using that approach, any question can belong to any number of categories, and any category can have any number of questions associated with it.
Structure would look something like this:
Upvotes: 2