Level 70
Ofcourse the second one where you have separated data into two tables. It's a more organized and systematic way.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, Which is better between 2 database schema for quiz?. Thank you.
Schema::create('questions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('questionnaire_id');
$table->string('question');
$table->string('option_a');
$table->string('option_b');
$table->string('option_c');
$table->string('option_d');
$table->string('correct_options');
$table->timestamps();
});
Or
Schema::create('questions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('questionnaire_id');
$table->string('question');
$table->timestamps();
});
Schema::create('answers', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('question_id');
$table->string('answer');
$table->tinyInteger('correct_answer')->default(false); // if 0 = false 1 = true
$table->timestamps();
});
The second option all day long.
It also gives you chance to add more fields to the answer, for instance if you wanted to show an image in relation to the answer, or additional text.
You might also want to add an 'sequence' field to the answer incase you want to show the answers in a particular order.
Please or to participate in this conversation.