开发者

does this table fit for the 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜