Second Normal
Second Normal
What is Dependency?
In this table, student_id is the primary key and will be unique for
every row, hence we can use student_id to fetch any row of data
from this table
Even for a case, where student names are same, if we know the
student_id we can easily fetch the correct record.
But this is not true all the time. So now let's extend our
example to see if more than 1 column together can act as a
primary key.
Let's create another table for Subject, which will have subject_id
and subject_name fields and subject_id will be the primary key.
subject_id subject_name
Index
1 Java
2 C++
3 Php
2 10 2 75 C++ Teacher
3 11 1 80 Java Teacher
Now as we just discussed that the primary key for this table is a
composition of two columns which is student_id & subject_id but the
teacher's name only depends on subject, hence the subject_id, and
has nothing to do with student_id.
There can be many different solutions for this, but out objective
is to remove teacher's name from Score table.
And our Score table is now in the second normal form, with no
partial dependency.
1 10 1 70
2 10 2 75
3 11 1 80
Quick Recap