我正在用Java编写一个小程序,我想如果将名称和出生日期放在文本字段中,它将获取学生在学期和考试中的成绩。在我制作的表格下方,我在链接这些表格时遇到问题:
您的数据库结构没有链接的可能性。
没有表具有可以将其链接到另一个表的键。
您必须识别一对多和多对多关联,并使用适当的键表示方法来表达它们。
例子:
我想表学生和表课程之间存在多对多的关系,您应该用这样的表来表达:
ideleve | idcourse
您必须在结构上计算出所有这些关系才能设计任何查询。
Following your comments I update the answer. In reality I should vot to close this question, as it is too broad and not over coding.
EXAMPLE OF PROBLEM SETTING:
Each student is identified by:
id | name | surname | born_date
Each course is identified by
id | course_title
Students can enroll in multiple courses
Courses can be held in 1st, 2nd semester or both maintaining the same id and title
There are up to 3 exams per course per semester
Notes of each exam can go from 1 to 5 with 1 being the lowest
Students have to take all the exams, if they do not take an exam their vote is considered 0 for that exam
This would led to a possible:
DB STRUCTURE
table students
id_student | name | surname
table courses
id_course | course_title
table exams
id_student | id_course | semester | exam | grade
with the implicit relations you can understand from columns names.
Then you can start with coding...
But here I am making a whole lot of assumptions on students, courses, exams and gardes and their relationships!
To design a DB an analysis of entities and relationships is needed.
the program you are trying to make is surely very simple as you say, also this analysis is not complex, but has to be done, and none can do that for you.
Following your last comment that finally clarify the problem you can do:
DB STRUCTURE
table students
id_student | name | surname | birthdate
table courses
id_course | course_title | year | semester
table exams
id_student | id_course | year | semester | test | exam | grade
example of table exams could be:
id_student | id_course | year | semester | test | exam | grade
--------------------------------------------------------------
2701 | K409 | 2015 | 1 | 1 | NULL | 4
2701 | K409 | 2015 | 1 | 2 | NULL | 4
2701 | K409 | 2015 | 1 | 3 | NULL | 4
2701 | K409 | 2015 | 0 | NULL | NULL | 3
2701 | K405 | 2015 | 1 | 1 | NULL | 4
2701 | K405 | 2015 | 1 | 2 | NULL | 4
2701 | K405 | 2015 | 1 | 3 | NULL | 4
2705 | K405 | 2015 | 0 | NULL | NULL | 3
2705 | K409 | 2015 | 2 | 1 | NULL | 4
2705 | K409 | 2015 | 2 | 2 | NULL | 4
2705 | K409 | 2015 | 2 | 3 | NULL | 4
2705 | K409 | 2015 | 0 | NULL | NULL | 3
2705 | K407 | 2015 | 2 | 1 | NULL | 4
2705 | K407 | 2015 | 2 | 2 | NULL | 4
2705 | K407 | 2015 | 2 | 3 | NULL | 4
2705 | K407 | 2015 | 0 | NULL | NULL | 3
You can link courses to exams/test using multi-columns key:
id_course-year-semester
link student to exams/test with:
id_student
通过您拥有的考试/测试表将学生链接到课程:
id_student | id_course-year-semester
这意味着当学生注册课程时,这样的记录将出现在考试/测试表中:
id_student | id_course | year | semester | test | exam | grade
--------------------------------------------------------------
2701 | K409 | 2015 | 1 | NULL | NULL | NULL
问候
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句