这个表适合 2NF 吗?
学生选择课程表。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它不是 2NF。这是:
学生:
课程:
Student_Courses:
因为您想要分解不完全依赖于原始候选键的属性(例如课程和学生编号)。所述属性仅部分依赖于原始候选键(例如,学分依赖于课程而不依赖于学生。年龄和姓名依赖于学生而不依赖于课程。)。对于每个部分依赖关系,您创建一个新表,以便属性完全依赖于新的候选/主键。
It is not 2NF. This is:
Students:
Courses:
Student_Courses:
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.
您的样本中没有足够的数据来确定所有决定因素是什么。
根据我们对学生和课程的了解,可以合理地猜测,学号决定姓名和年龄,所选课程决定学分。假设(学生编号,所选课程)是该表的候选键也是合理的。这都是根据每个人之前对学生和课程的经验进行的猜测。
正确的解决方案在另一个回复中已经给出,只不过引入一个新的数据项“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.