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 8534335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:10:15+00:00 2026-06-11T10:10:15+00:00

I am in the process of writing a web-based quiz application using PHP and

  • 0

I am in the process of writing a web-based quiz application using PHP and MySQL. I don’t want to bore you with the details of it particularly, so here’s what (I think) you need to know.

Questions are all multiple choice, and can be stored in a simple table with a few columns:

  1. ID: The question number (primary index)
  2. Category: The category this question falls under (e.g. animals,
    vegetables, minerals)
  3. Text: The question stem (e.g. What is 1+1?)
  4. Answer1: A possible answer (e.g. 2)
  5. Answer2: A possible answer (e.g. 3)
  6. Answer3: A possible answer (e.g. 4)
  7. CorrectAnswer: The correct answer to the question (either 1, 2 or 3 (in this case 1))

Users can sign up by creating a username and password, and then attempt questions from categories.

The problem is that the questions I’m writing are designed to be attempted more than once. However, users need to be given detailed feedback on their progress. The FIRST attempt at a question matters, and contributes to a user’s overall ‘questions answered first time’ score. I therefore need to keep track of how many times a question has been attempted.

Since the application is designed to be flexible, I would like to have support for many hundreds of users attempting many thousands of questions. Thus, trying to integrate this information into the user table or questions table seems to be impossible. The way I would like to approach this problem is to create a new table for each user when they have signed up, with various columns.

  1. Table Name: A user’s individual table (e.g. TableForUser51204)
  2. QuestionID: The ID of a question that the user has attempted.
  3. CorrectFirstTime: A boolean value stating whether or not the
    question was answered correctly first time.
  4. Correct: The number of times the question has been answered
    correctly.
  5. Incorrect: The number of times the question has been answered
    incorrectly.

So I guess what I would like to ask is whether or not organising the database in this manner is a wise thing to do. Is there a better approach rather than creating a new table for each user? How much would this hinder the performance if there are say 500 users and 2000 questions?

Thanks.

  • 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-06-11T10:10:17+00:00Added an answer on June 11, 2026 at 10:10 am

    You don’t want to be creating a new table per user. Instead, modify your database structure.

    Normally, you’d have a table for questions, a table for options (with maybe a boolean column to indicate if it’s the correct answer), a users table, and a join table on users and options to store users’ responses. A sample schema:

    CREATE TABLE `options` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `question_id` int(10) unsigned NOT NULL,
      `text` varchar(255) NOT NULL,
      `correct` tinyint(1) NOT NULL,
      PRIMARY KEY (`id`),
      KEY `question_id` (`question_id`)
    ) TYPE=InnoDB;
    
    CREATE TABLE `options_users` (
      `option_id` int(10) unsigned NOT NULL,
      `user_id` int(10) unsigned NOT NULL,
      `created` timestamp NOT NULL,
      KEY `option_id` (`option_id`),
      KEY `user_id` (`user_id`)
    ) TYPE=InnoDB;
    
    CREATE TABLE `questions` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `question` varchar(255) NOT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `id` (`id`,`question`)
    ) TYPE=InnoDB;
    
    CREATE TABLE `users` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `username` varchar(60) NOT NULL,
      `password` char(40) NOT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `username` (`username`)
    ) TYPE=InnoDB;
    
    
    ALTER TABLE `options`
      ADD CONSTRAINT `options_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
    
    ALTER TABLE `options_users`
      ADD CONSTRAINT `options_users_ibfk_2` FOREIGN KEY (`option_id`) REFERENCES `options` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
      ADD CONSTRAINT `options_users_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
    

    This links options to questions, and users’ responses to options. I’ve also added a created column to the options_users table so you can see when a user answered the question and track their progress over time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am in the process of writing a new web application. I am using
I am in the process of writing a Java based web site. I am
I am currently writing an web application where you need to log in, using
I am writing a stateful web application in PHP in which the state potentially
I am writing a web application using GWT and App Engine. My application will
I am in the process of writing a JSON based web service. The service
I'm in the process of writing an application to suggest circular routes over OpenStreetMap
I am in the process of writing an enterprise-level application utilizing WCF and NetTCP
I am in the process of writing some validation code based on these assumptions:
I am in the process of writing a web app that includes a reporting

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.