duaner1634 2014-03-23 00:31
浏览 17
已采纳

PHP MySQL日志的其他提交

I have an online Test Taking System where once the user submits the test form it adds a row to the table like so;

Employee ID | Employee Name | Date Test 1 Taken

Employees can retake tests so I want to replace the 'Date Test 1 Taken' with the date of the most recent submission, however, I also want to log all the previous submissions.

So basically I'd want a second table with 3 previous submissions like so; Employee ID | Previous Submission 1 | Previous Submission 2 | Previous Submission 3

Is it possible to essentially do "This employee retook this test on a different date, so take the current date in 'Date Test 1 Taken', move it to the other table under 'Previous Submission 1' and place the current date in 'Date Test 1 Taken'? Is it extremely complicated, if at all possible..?

  • 写回答

1条回答 默认 最新

  • doucuo8618 2014-03-23 00:47
    关注

    I would suggest a design improvement. It seems your goal is to keep a running record of each employee and test type. Your table should be something like:

    EmployeeTest table: EmployeeID, EmployeeName, TestNum, DateTaken, Score
    

    You insert a row to the EmployeeTest table for every test taken. You can then write queries like:

    select EmployeeID, EmployeeName, TestNum, DateTaken, Score from EmployeeTest order by DateTaken
    

    To see all test for an employee in date order. Or:

    select EmployeeName, TestNum, max(DateTaken), Score from EmployeeTest where EmployeeID = 'joe' and TestNum = 1
    

    To get the latest date and score for employee 'joe' for test #1

    Of course the EmployeeName should be broken out into an Employee table (EmployeeID, EmployeeName), but I didn't want to muddy the issue with joins at this point.

    Have fun...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图