I know there's a similar questions to this one here. My question builds on that answer.
I am building a web app that will allow a user to create quizzes for educational purposes. This implies that there will be hundreds of questions created.
Option 1
In the quoted answer the method suggested is to use a ForeignKey relationship as such:
class Question(models.Model):
prompt = models.TextField (max_length=300)
answer = models.CharField (max_length=50)
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice = models.CharField (max_length=300, blank=True)
However, the problem with this method is that if I have 300 questions, that will create 1200-1800 or choice entries. As there are more and more questions created, that number will grow by 10. As an educator, I plan to use this for my work (I have several thousand questions) and share the app with other teachers who will all be adding and sharing their own questions. I am concerned that on a larger scale this will create performance issues with the database.
Option 2
What has been suggested to me is to use this approach instead:
class Question(models.Model):
prompt = models.TextField (max_length=300)
answer = models.CharField (max_length=50)
class ChoiceList(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice1 = models.CharField (max_length=300, blank=True)
choice2 = models.CharField (max_length=300, blank=True)
choice3 = models.CharField (max_length=300, blank=True)
choice4 = models.CharField (max_length=300, blank=True)
choice5 = models.CharField (max_length=300, blank=True)
choice6 = models.CharField (max_length=300, blank=True)
choice7 = models.CharField (max_length=300, blank=True)
choice8 = models.CharField (max_length=300, blank=True)
choice9 = models.CharField (max_length=300, blank=True)
choice10 = models.CharField (max_length=300, blank=True)
Option 3
There is a third alternative here as well, which is to store the answers as in the first example but by using a list [choice1, choice2, choice3...]. That way avoids null values and also would not create 6 average choice entries per question entry.
Are there any issues that I am not foreseeing by creating a single entry of ChoiceList for each Question?
Which approach will be most effective for my app?