Database Design For Developing 'Quiz' Web Application using PHP and MySQL

前端 未结 4 903
旧时难觅i
旧时难觅i 2020-12-22 18:40

So, I\'m trying to learn PHP and MySQL (I have a basic understanding of both; I\'ve read the first half of both Head First SQL and Head First PHP & MySQL) and I figure t

4条回答
  •  情书的邮戳
    2020-12-22 19:04

    I am not sure how new you are to programming in general, but even if you are just getting started, I would recommend you use a framework.

    Using a framework will guide you by providing best-practice implementations of the tools you'll need in your project.

    I personally use Symfony for php projects, and I would suggest you check out their guides and tutorials. Symfony is a well-established framework and it's based on widely accepted designs.

    To answer your question more directly, though, I would suggest something like this for your application:

     - user
      - id (PK)
      - last_name
      - first_name
      - email
      - gender
    
    
     - quiz
      - id (PK)
      - title
    
    
     - quiz_question
      - id (PK)
      - quiz_id (FK)
      - text
    
     - quiz_question_option
      - id (PK)
      - quiz_question_id (FK)
      - text
      - is_correct
    
     - quiz_user_answer
       - id (PK)
       - quiz_question_id (FK)
       - quiz_question_option_id  // this is the answer.
    

    The above would allow you to define multiple quizes each having multiple questions and create answer sets (a user's set of answers to a quiz) and record each answer.

    Hope that helps :)

提交回复
热议问题