What alternative database design approaches can be considered to avoid the need for dynamically adding columns to store answers in a quiz application?

One alternative database design approach to avoid the need for dynamically adding columns to store answers in a quiz application is to use a relational database structure with separate tables for questions, answers, and quizzes. This way, answers can be stored in a separate table linked to the questions table through foreign keys, allowing for flexibility in storing and retrieving answers without the need to add columns dynamically.

// Example of database structure for quiz application

CREATE TABLE questions (
    id INT PRIMARY KEY,
    question_text VARCHAR(255)
);

CREATE TABLE answers (
    id INT PRIMARY KEY,
    question_id INT,
    answer_text VARCHAR(255),
    is_correct BOOLEAN,
    FOREIGN KEY (question_id) REFERENCES questions(id)
);

CREATE TABLE quizzes (
    id INT PRIMARY KEY,
    quiz_name VARCHAR(255)
);

CREATE TABLE quiz_questions (
    quiz_id INT,
    question_id INT,
    FOREIGN KEY (quiz_id) REFERENCES quizzes(id),
    FOREIGN KEY (question_id) REFERENCES questions(id)
);