数据库中的建模课程和先决条件 [英] Modeling courses and pre-requisites in the database

查看:96
本文介绍了数据库中的建模课程和先决条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本情况:我有学生,课程和课程要求需要存储在数据库中。

Basic scenario: I have students, courses, and course-requirements that need to be stored in the database.

任何人都有了解最好的存储方式这些和遍历课程的先决条件?

Anyone has any insight into the best way to store these and traverse course prerequisites?

1)简单的例子:


  • C:数学100,prereq:无

  • C:Math 150,prereq:none

  • C:Math 200,prereq:Math 101,Math 150

  • C: Math 100, prereq: none
  • C: Math 150, prereq: none
  • C: Math 200, prereq: Math 101, Math 150

学生一个完成的数学100.如何确定他是否有资格通过数据库查询获取CS200?

Student A completed Math 100. How does one determine if he is eligible to take CS200 via database querying?

2)更复杂的例子:


  • C:Chem 100,prereq:none
  • $ b $ C:Chem 200,prereq:Chem 100
  • C:Chem 201,prereq:Chem 200

  • C:Chem 202,prereq :Chem 200

  • C:Chem 300,prereq:Chem 200,Chem 201,Chem 202中的任何两个

  • C: Chem 100, prereq: none
  • C: Chem 200, prereq: Chem 100
  • C: Chem 201, prereq: Chem 200
  • C: Chem 202, prereq: Chem 200
  • C: Chem 300, prereq: any two of Chem 200, Chem 201, Chem 202

学生B完成Chem 100,Chem 200,Chem 203.你如何检查他是否有资格参加Chem 300?

Student B completed Chem 100, Chem 200, Chem 203. How do you check that he is eligible to take Chem 300?

如何建模数据库中的必需层次结构?任何建议,链接和参考将是最受欢迎的。

How to model the pre-requisites hierarchy in the database? Any advice, links, references would be most welcome.

推荐答案

有几件事您没有想过,如实体这需要被定义,这在你的问题中是隐含的。允许我加入一些,但不要让他们分心,我正在关注你提出的问题。您现在可以安全地忽略成绩,老师等,并考虑未来。

There are are few things you have not thought about, as in Entities that need to be defined, that are implicit in your question. Permit me to include a few, but do not get distracted by them, I am focusing on your stated question. You can safely ignore Grade, Teacher, etc for now and contemplate them for the future.

大学的典型数据模型

IDEF1X符号 ,需要解释符号。

IDEF1X Notation, for those who need explanation of the symbols.


  • 没有必要添加替代钥匙,除非它们是必需的,因为自然钥匙变得太大,不能携带到孩子身上;我没有盲目地把它们贴在每张桌子上的PK上。在任何情况下,考虑是物理而不是逻辑的水平。

  • There is no need to add Surrogate keys unless they are required, due the the natural key becoming too large to carry into the children; I have not blindly stamped them as PK on every table. In any case, the consideration is at the physical, not logical level.

我为当地一所大学建立了一个RDB。我认为,除了任何两个...之类的先决条件,您可能需要至少有一个,所以我有

I modelled a RDb for a local university once. I think in addition to pre-requisites such as "any two of ...", you may need "and at least one of ...", so I have provided for any combination of those.

必需条件包含可能的必需条件的完整列表

Requisite contains the full list of possible requisites


  • IsMandatory 标识需要履行 ;剩余的不是,并且落入任何两个...

  • IsMandatory identifies that the Requisite is Madatory required to fulfil the "at least one of ..."; the remainder are not, and fall into the "any two of ..."

/ code>允许将最低成绩指定为必需

Grade allows a minimum Grade to be specified as requisite .

如果您需要SQL代码浏览结构,请问。

If you need SQL code to navigate the structure, please ask.

这篇关于数据库中的建模课程和先决条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆