Home  >  Q&A  >  body text

mysql - 选课系统数据库课程数据表的设计?

大概就是一个选课系统的网站,其中要实现学生选课的功能,一般课程的时间都是周X 第X节到第X节,然后我就不知道数据表里面的time字段该怎么搞了。。。


感觉放date类型也不对,放string类型也很怪,而且还要展示学生的课表,到时候肯定还是按时间来展示的。。所以求指点这个字段该怎么设计?

高洛峰高洛峰2742 days ago639

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-17 16:48:49

    You can separate courses, students, schedules, and course selection relationships into four separate tables.

    课程表
        课程ID
        课程名称
        讲师姓名
        第几周到第几周
        ...
    学生
        学生ID
        学生姓名
        ...
    日程表
        日程ID
        课程ID
        星期几
        第几节课
        ...
    选课关系
        选课关系ID
        学生ID
        课程ID

    Now that you know the name of the student, if you want to search for those classes that you will take tomorrow afternoon, just do this:
    Get the student ID based on the name from the student table, and get the course IDs of all the courses he has chosen based on the student ID from the course selection relationship, from The course schedule gets the start and end time of each course based on the course ID, keeping those courses that match tomorrow's date. Then get the courses that may be taken tomorrow afternoon from the schedule based on the course ID.
    That’s about it, I think. I've never done anything like this, so I just made a guess. Hope that helps.

    reply
    0
  • Cancelreply