second normal form

a relation schema is in 2NF if every nonprime attribute in is fully functionally dependent on the primary key of .
[cite:;from @elmasri_db_2015 chapter 14.4.1 general definition of second normal form]
the test for 2NF involves testing for functional dependencies whose left-hand side attributes are part of the primary key. if the primary key contains a single attribute, the test need not be applied at all. if a relation schema is not in 2nf, it can be second normalized or 2nf normalized into a number of 2NF relations in which nonprime attributes are associated only with the part of the primary key on which they are fully functionally dependent.
[cite:;see @elmasri_db_2015 chapter 14 basics of functional dependencies and normalization for relational databases]
a relation pertains the 2nf normalization degree if
  • it pertains the 1nf normalization degree;
  • every field that isnt part of a key is fully functionally dependent on the whole key. i.e. a field that isnt part of the key cannot be functionally dependent on only part of the key.
in a relation with 1 field only the 2nf normalization degree is vacuously satisfied.
the process of 2nf normalization is as follows. when a partial functional dependency is present, denoted by where is part of the key:
  1. we copy the functional dependency into a new relation, in which is the key.
  2. we delete from the original relation.
consider the following relation:
(_student id, course code_, student name, course name, grade)
here, we have a multivalued dependency between course code and student id, both of which are in the key of the relation. and both determine functionally the grade. but student name is dependent on student id only, and course name is dependent on course code only, so we need to normalize them according to 2nf. the modified schema becomes:
  • students (_student id_, student name)
  • courses (_course code_, course name)
  • grades (_student id, course code_, grade)