Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7625409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:11:18+00:00 2026-05-31T05:11:18+00:00

So my objective sounds simple, I need to make a db driven multiple choice

  • 0

So my objective sounds simple, I need to make a db driven multiple choice quiz
CMS to add into my project. I need to be able to create quizzes by category, add 10 questions per quiz, and 4 questions with 1 answer. I’ve been troubled in 2 areas.

  1. Database structure. How can I structure my database so that I can do this? eg, a table for each questions, question_answers, and quizzes?

  2. After the users takes the quiz, I want to grab the score and store it into its own table. I know how to put the score into the database, but how would I display the quiz, with the corresponding question, with the corresponding answers, and the correct answer with the right radio button?

It’s very tricky to me, but maybe not to some of you geniuses out there.

Best regards,

Sean

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:11:18+00:00Added an answer on May 31, 2026 at 5:11 am

    Clicked this table structure for you. The foreign key constraints are optional.

    CREATE TABLE IF NOT EXISTS `answer` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `question_id` int(10) unsigned NOT NULL,
      `answer` varchar(100) NOT NULL,
      PRIMARY KEY (`id`),
      KEY `question_id` (`question_id`)
    ) ENGINE=InnoDB ;
    
    CREATE TABLE IF NOT EXISTS `question` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `quiz_id` int(10) unsigned NOT NULL,
      `question` varchar(500) NOT NULL,
      `correct_anwer_id` int(10) unsigned NOT NULL,
      PRIMARY KEY (`id`),
      KEY `quiz_id` (`quiz_id`,`correct_anwer_id`),
      KEY `correct_anwer_id` (`correct_anwer_id`)
    ) ENGINE=InnoDB ;
    
    CREATE TABLE IF NOT EXISTS `quiz` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `category` int(10) unsigned NOT NULL,
      `title` varchar(100) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB ;
    
    ALTER TABLE `answer`
      ADD CONSTRAINT `answer_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`);
    
    ALTER TABLE `question`
      ADD CONSTRAINT `question_ibfk_2` FOREIGN KEY (`correct_anwer_id`) REFERENCES `answer` (`id`),
      ADD CONSTRAINT `question_ibfk_1` FOREIGN KEY (`quiz_id`) REFERENCES `quiz` (`id`);
    

    And for storing the test, users have taken:

    CREATE TABLE IF NOT EXISTS `test` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `user_id` int(10) unsigned NOT NULL,
      `quiz_id` int(10) unsigned NOT NULL,
      `date_taken` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `score` mediumint(9) NOT NULL,
      PRIMARY KEY (`id`),
      KEY `quiz_id` (`quiz_id`)
    ) ENGINE=InnoDB ;
    
    CREATE TABLE IF NOT EXISTS `test_answer` (
      `test_id` int(10) unsigned NOT NULL,
      `question_id` int(10) unsigned NOT NULL,
      `answer_id` int(10) unsigned NOT NULL,
      `single_score` mediumint(9) NOT NULL,
      PRIMARY KEY (`test_id`,`question_id`),
      KEY `question_id` (`question_id`),
      KEY `answer_id` (`answer_id`)
    ) ENGINE=InnoDB ;
    
    ALTER TABLE `test`
      ADD CONSTRAINT `test_ibfk_1` FOREIGN KEY (`quiz_id`) REFERENCES `quiz` (`id`);
    
    ALTER TABLE `test_answer`
      ADD CONSTRAINT `test_answer_ibfk_3` FOREIGN KEY (`answer_id`) REFERENCES `answer` (`id`),
      ADD CONSTRAINT `test_answer_ibfk_1` FOREIGN KEY (`test_id`) REFERENCES `test` (`id`),
      ADD CONSTRAINT `test_answer_ibfk_2` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`);
    

    Some sample data to play around:

    INSERT INTO `answer` (`id`, `question_id`, `answer`) VALUES
    (3, 1, 'stackoverflow.com '),
    (4, 1, 'example.com');
    
    INSERT INTO `question` (`id`, `quiz_id`, `question`, `correct_anwer_id`) VALUES
    (6, 1, 'What is the best website on the whole internet?', 3);
    
    INSERT INTO `quiz` (`id`, `category`, `title`) VALUES
    (1, 1337, 'My Great Quiz. Take me!');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am newbie to objective-c.So apologies in advance if this question sounds simple.As we
Objective : Make a progress bar where users can check how much of a
Objective: In support of a Windows Service that may have multiple instances on a
I need to create a music sequencer for the iPad but have no experience
This sounds like a simple one but I can't find the solution anywhere. How
I know this sounds like a subjective answer, but I will try to make
I'm testing MonoTouch (the idea of developing in C# rather than objective-C sounds great).
I'm coding in Objective-C for the iPhone and I am trying create an array
I'm new to objective-c and need to extend a standard class of a framework
i'm new with the iphone and objective c, so far, I have been able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.