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 the best way to solidify my knowledge is by building something rather than reading.

我正在学习PHP和MySQL(我对这两个都有基本的了解;我读过Head first SQL和Head first PHP和MySQL的前半部分,我认为巩固知识的最好方法是构建一些东西,而不是阅读。

With that in mind, I would like to create a basic webpage that connects to a MySQL database on a server. I will build a basic HTML form and allow users to input basic information, such as: last_name, first_name, email, birthday, gender.

考虑到这一点,我想创建一个基本的网页,连接到服务器上的MySQL数据库。我将构建一个基本的HTML表单,允许用户输入基本信息,比如:last_name、first_name、email、生日、性别。

My problem is I don't know how to design a database that will record the results of a basic quiz - I want just 5 multiple-choice problems. Eventually, I would like to display the results of the user versus the previous users' results.

我的问题是我不知道如何设计一个数据库来记录一个基本测试的结果——我只想要5个多项选择题。最后,我想显示用户的结果和以前用户的结果。

If you could help me understand how to design table(s) for a 5-question Quiz I'd appreciate it. Thanks!

如果你能帮助我理解如何为一个5个问题的小测验设计表格,我会很感激的。谢谢!

4 个解决方案

#1


28

I would start with 4 simple table:

我将从4个简单的表开始:

 * User
   - user_id    auto integer
   - regtime    datetime
   - username   varchar
   - useremail  varchar
   - userpass   varchar
 * Question
   - question_id   auto integer
   - question      varchar
   - is_active     enum(0,1)
 * Question_choices
   - choice_id        auto integer
   - question_id      integer
   - is_right_choice  enum(0,1)
   - choice           varchar
 * User_question_answer
   - user_id      integer
   - question_id  integer
   - choice_id    integer
   - is_right     enum(0,1)
   - answer_time  datetime

My though on this table design is:

我的想法是:

  • table User is for storing registered user.
  • 表用户用于存储已注册用户。
  • table Question is for storing all your question. It has is_active so that you can selectively display only active question (using WHERE is_active = '1')
  • 表格问题是用来储存你所有的问题。它具有is_active,因此您可以选择性地显示活动问题(使用is_active = '1')
  • table question_choices is for storing all available options. It has is_right_choice which define what choice is the right answer for particular question.
  • 表question_choices是用于存储所有可用选项的。它有is_right_choice,定义了什么选项是特定问题的正确答案。
  • Table User_question_answer is for storing answer from your user. It has is_right for faster lookup, to see whether that particular question and answer choice is right (based on is_right_choice previously defined). It also has answer_time just to note when that particular user answer the question.
  • 表User_question_answer用于存储用户的答案。它有is_right用于快速查找,以查看特定的问题和答案选择是否正确(基于前面定义的is_right_choice)。它还有answer_time,只注意特定用户何时回答问题。

更多相关文章

  1. Laravel Auth只验证管理员/超级用户
  2. 在phpword中如何在表格中新建行?
  3. 用户GROUP BY ERROR之间的SQL查询privatemsgs
  4. 使用PHP显示用户输入
  5. 根据网址上的国家/地区将用户重定向到正确的数据库,我使用i18n fo
  6. PHP结合Redis来限制用户或者IP某个时间段内访问的次数
  7. 使用JOIN获取有关两个用户的信息
  8. PHP:如果用户没有按下提交按钮,则Mysql回滚多个查询(通过ajax完成)
  9. 当excel表格单元格的格式是日期格式非文本格式的时候,phpexcel 应

随机推荐

  1. 在Android平台上实现条型码扫描与识别
  2. Android2.3发布
  3. Android 布局之LinearLayout和RelativeLa
  4. Android 2.2新增Widget之ProtipWidget源
  5. Android启动脚本init.rc
  6. 布局中文件中【控件间距参数详解以及单位
  7. MediaRecorder视频的录制和播放
  8. Android(安卓)+ eclipse +ADT安装完全教
  9. Android开发者e周报 第1期
  10. ubuntu 9.04上下载android源码