Pierre56
Pierre56

Reputation: 567

MySQL - Multiple choice question - New table to store question category?

I am working on a multiple choice question form. I am using Flask on the back-end and MySQL as a database.

There will be more than 1 end-user. I already made a users table but haven't work on it yet There are multiple questions but I only display one question at once. Every question have either 3 or 4 possible choices (A, B, C or A, B, C, D) There is always one correct answer The user can filter question based on category and get stats by category (% of question answered for this category for example) Should I create a new table called category which would look like category_id (int, primary_key), category_text (varchar(50))? MySQL )

Upvotes: 0

Views: 198

Answers (1)

Neo
Neo

Reputation: 809

In my opinion, it is better to have the mentioned separate category table for the following reasons:

  • Restrict the categories to a predefined limited set.
  • You might need only categories regardless of question related data. Reading from questions table to just get category data would hint design issues.
  • Avoid having category as a free text in the questions table to avoid mistakes that would need cleanups in the future and complicates grabbing/filtering data.
  • Easily extensible if you want to add more information through columns in the category table afterwards.

Upvotes: 1

Related Questions