I'm aware this is normally a bad idea, and I've done my reading - in particular, this question.
However the total normalisation route seems more complex and will give me and my code more hoops to jump through. Here's my scenario:
I'm building a test creation system where users can create tests, questions and answers, and associate them all together, i.e. associate answers with questions, and questions with tests. This approach means there's no hard-linking any one kind of data to any other; a given question can be part of two or more tests, for example. So, I was thinking (simplified):
Tests table:
- id (PK)
- name (varchar)
- questions (com-sep list of question IDs)
Questions table:
- id (PK)
- question text (varchar)
- answers (com-sep list of answer IDs)
Answers table:
- id (PK)
- answer text (varchar)
So a given row in the tests table might look like:
---------------------------------------
| ID | NAME | QUESTIONS |
---------------------------------------
| 1 | SOME TEST | 1,4,7,8,11,19 |
---------------------------------------
Then, when I fetch a test and its questions, I just do some magic with group concat
.
Question: is this all a bad idea? It seems a lot simpler than the alternative which is to have two further tables dedicated, respectively, to logging associations between tests and questions, and questions and answers, meaning more tables involved in any queries.