这个表适合 2NF 吗?

发布于 2024-10-10 07:02:09 字数 272 浏览 1 评论 0原文

学生选择课程表。

 studentnumber   name     age     selected course   credit

    1             tom      23            math           5

    2              jim      20          computer         4

........

如果该表不适合 2NF,为什么以及如何纠正它。谢谢。

a student select course table.

 studentnumber   name     age     selected course   credit

    1             tom      23            math           5

    2              jim      20          computer         4

........

if the table doesn't fit for the 2NF, why and how to correct it. thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你怎么敢 2024-10-17 07:02:09

它不是 2NF。这是:

学生:

studentnumber   name     age    

1               tom      23            
2               jim      20     

课程:

coursenumber   name      credit

1              math      5
2              computer  4

Student_Courses:

studentnumber  coursenumber

1              1
2              2

因为您想要分解不完全依赖于原始候选键的属性(例如课程和学生编号)。所述属性仅部分依赖于原始候选键(例如,学分依赖于课程而不依赖于学生。年龄和姓名依赖于学生而不依赖于课程。)。对于每个部分依赖关系,您创建一个新表,以便属性完全依赖于新的候选/主键。

It is not 2NF. This is:

Students:

studentnumber   name     age    

1               tom      23            
2               jim      20     

Courses:

coursenumber   name      credit

1              math      5
2              computer  4

Student_Courses:

studentnumber  coursenumber

1              1
2              2

Because you want to break out attributes which are not wholly dependent on the originally candidate key (e.g. course and studentnumber). Said attribues were only partially dependent on the the orignal candidate key (e.g. credit was dependent on course but not student. Age and name were dependent on student but not course.). For each partial dependency, you create a new table so that the attributes ARE wholly dependent on the new candidate/primary key.

看透却不说透 2024-10-17 07:02:09

您的样本中没有足够的数据来确定所有决定因素是什么。

根据我们对学生和课程的了解,可以合理地猜测,学号决定姓名和年龄,所选课程决定学分。假设(学生编号,所选课程)是该表的候选键也是合理的。这都是根据每个人之前对学生和课程的经验进行的猜测。

正确的解决方案在另一个回复中已经给出,只不过引入一个新的数据项“coursenumber”并不是将数据放入2NF的严格必要条件,前提是没有两门课程可以有相同的“所选课程”。然而,发明课程编号可能是个好主意。

There isn't enough data in your sample to figure out what all the determinants are.

From what we know of students and courses, its reasonable to guess that studentnumber determines name and age, and also that selected course determines credit. It's also reasonable to assume that (student number, selected course) is a candidate key for the table. This is all guess work, based on everybody's prior experience with students and courses.

The correct solution has been given in another response, except that the introduction of a new data item, namely "coursenumber" is not strictly necessary to put the data into 2NF, provided that no two courses can have the same "selected course". Inventing course numbers is probably a good idea, however.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文