1

我正在为我的大学申请设计一个数据库。报告实体如下:

在此处输入图像描述

每个report人都有一个students, courses和学生的列表rating

问题是随着时间的推移,课程和学生人数可能会发生变化。数据库结构应该灵活且易于适应这些变化。对于这种情况,如何最好地在关系数据库中定义这些实体和设计表之间的关系?

我对这件事有一些想法。也许这个模型最能描述关系并解决问题的问题:在此处输入图像描述

还是这种关系是REPORT to STUDENT多余的和多余的?一份关系是否足够一份报告?例如仅REPORT to COURSE没有 REPORT to STUDENT在此处输入图像描述 哪个选择更好,为什么?这种结构还有其他缺点吗?

提前感谢您的建议!

4

2 回答 2

0

不要在学生表或课程表中包含指向“报告”表的链接。我建议您使用以下结构:

STUDENT
id
forename
surname
dob  
... other fields

LECTURER
id
forename
surname
honorific (Mr/Dr/Professor, etc)
department id
... other fields

COURSE
id
name
duration
credits

SEMESTER
id
course id
lecturer id

RATINGS
semester id
student id
mark

通过这种方式,您可以参加由多位讲师在不同日期教授的课程(例如经济学概论)。学生注册特定学期并获得该学期的分数。如果您希望学生在给定课程/学期中获得多个分数,则将日期字段添加到评分表中。

您的报告通常会查询评级表。

于 2013-03-25T09:40:44.480 回答
0

"the report is a set of ratings?" Yes

OK, that clears things a little bit. I'm still unceratin as to what exactly are you trying to model, but I'll give it a stab:

enter image description here

The RATING PK1 ensures no student can rate the same course more than once. A report is simply a set of ratings.

This structure does not ensure that all ratings in the report are related to the same course, nor it enforces the course attendance in any way2.


1 Specifically, the fact that REPORT_ID is outside the PK, so one rating cannot be part of multiple reports. If you want the opposite, you cannot just include that field in the PK since that would allow for different VALUEs - you'll need a proper junction table instead.

2 You might want to forbid a rating of a course by a student that did not attend the course. Let me know how you intend to represent the course attendance and I might have some ideas how to connect that to ratings and reports...

于 2013-03-26T23:39:20.407 回答