课程先决条件的数据库设计
我目前正在开发一个示例课程注册系统,我需要维护该系统的课程先决条件。我必须在页面上将类先决条件显示为布尔表达式。 例子: 如果学生正在查看 A 类,则先决条件必须显示为 (B 和 C) 或 D
我不知道如何处理这个问题。
到目前为止的设计: 一个类有很多部分。 Class(*deptartment, class_number*, description)
斜体是主键。有什么建议如何处理先决条件吗?
课程数据示例: (CMSC,201,编程1) (CMSC,202,编程2) (CMSC,203,离散结构) (CMSC,341,数据结构)
I am currently working on a sample class registration system for which I need to maintain class prerequisites. I have to display class prerequisites on page as a boolean expression.
Example:
If a student is viewing Class A, prerequisites must be displayed as (B AND C) OR D
I am not sure how to handle this.
Design so far:
A Class have many sections.
Class(*deptartment, class_number*, description)
Italics are primary keys. Any suggestions how to handle prerequisites??
Example data for course:
(CMSC,201,Programming 1)
(CMSC,202,Programming 2)
(CMSC,203,Discrete Structures)
(CMSC,341,Data Structures)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要添加达菲莫的一对多关系建议,请向该关系添加分组。组 ID 将是您的括号。因此,您的表可能如下所示:
prereq_group 只需在 class_id 中唯一,并且可以是连续的数字。如果 prereqs 具有相同的组 id,那么它们将是 AND。不同的组 ID 将是一个 OR。因此,在上面的示例中,它将是 (B AND C) OR (D)。
To add to duffymo's suggestion of a one-to-many relationship, add grouping to that relation. The group ID would then be your parenthesis. So your table may look like this:
The prereq_group only needs to be unique within the class_id and could be a sequential number. If prereqs have the same group id, then they would be AND. Different group ids would be an OR. So in the above example, it would be (B AND C) OR (D).
该部分与先决条件无关。
听起来像是一对多的关系。
我不确定通过成绩是否需要成为您的先决条件的一部分。如果是,您还有更多工作要做,因为您需要 Student 和 ReportCard 表来管理先决条件。
Section is irrelevant for prerequisites.
It sounds like a one-to-many relationship.
I'm not sure if a passing grade needs to be part of your prerequisites. If yes, you've got more work to do, because you'll need Student and ReportCard tables to manage Prerequisites.
看起来像一个不平凡的设计案例......就 iv 所看到的数据库设计而言,不可能有单一的连接条件而不丢失 1NF。
一个建议的解决方案,可以在不丢失 1NF 的情况下遇到多个自连接 -
假设按班级你的意思是课程......
先决条件(precession_id(pk),class_no*(fk),relation,Linked_Precessions(fk)*)
如果 Linked_Precessions 为 null,我们可以继续使用特定 class_no 下的所有可用行来查找所有先决条件。
例如,
使用它您可以创建一个有向图。最初,您可以从先决条件中选择数据,使其具有非空数据,然后将其与其自身连接以在其内部创建层次结构。
如果您自己维护数据,您可以操纵它在单级有向图中工作,您只需编写一个一级连接。
Seems like a non trivial design case...As far as iv seen DB designs there can be no single join condition without losing 1NF on this.
A suggested solution which can run into multi self joins without losing 1NF-
Assuming by class u mean course...
prerequisites(prerequisite_id(pk),class_no*(fk),relationship,Linked_Prerequisites(fk)*)
if Linked_Prerequisites is null we can go on using to club all rows available under a particular class_no to find all prerequisites.
eg
Using this you can create a directed graph. Initially u can select data from prerequisites such that they have non null data and then join it with itself to create a hierarchy within itself.
If you maintain the data yourself u can manipulate this to work at a single level directed graph with which u will have to write just a one level join.