Professional Documents
Culture Documents
UNIT5 Normalisation Dependency
UNIT5 Normalisation Dependency
UNIT5 Normalisation Dependency
Functional dependency
• A functional dependency is an association between
two attributes of the same relational database table.
• One of the attributes is called the determinant and
the other attribute is called the determined.
• For each value of the determinant there is
associated one and only one value of the
determined.
Functional dependency
• If A is the determinant and B is the determined then
we say that A functionally determines B and
graphically represent this as A -> B. The symbols A -
>B· can also be expressed as B is functionally
determined by A.
Since for each value of A there is associated one and only one value of B.
Example
For example, Consider a Relation R(A,B,C,D,E) having FD : AB → CDE where PK is AB. Then, { A → C
; A → D; A → E; B → C; B → D; B → E } all are Partial Dependencies.
Transitive Dependency –
• Normalization
Data normalization is a technique of organizing the data in database.
Normalization of data can be defined as a process during which
redundant relation schemas are decomposed by breaking up their
attributes into smaller relation schemas that process desirable
properties
Normalisation
First Normal Form
C1
Visual Basic
ABC
100
A1
P–I
20
7
C1
Visual Basic
ABC
101
A2
P – II
30
3
C1
Visual Basic
ABC
102
A3
Celeron
10
6
C1
Visual Basic
ABC
103
A4
P – IV
40
1
C2
Oracle & Dev
DEF
100
A1
P–I
20
7
C2
Oracle & Dev
DEF
104
A5
P – III
35
3
C2
Oracle & Dev
DEF
105
A6
P – II
30
1
C2
Oracle & Dev
DEF
101
A2
P – II
30
2
C3
C++
KJP
106
A7
P – IV
40
3
C3
C++
KJP
107
A8
P – IV
40
2
C3
C++
KJP
108
A9
P–I
20
1
C4
Java
Kumar
109
A10
Cyrix
20
2
Approaches to normalize table
STUDENT (Decomposition)Normalised
Data Course Roll Name System Hourly Total
Course Course Name Teacher
Code Name
Code
No
Used
Rate
Hours
C1 102 A3 Celeron 10 6
C3 C++ KJP
C1 103 A4 P – IV 40 1
C4 Java Kumar
C2
100
A1
P–I
20
7
C2
104
A5
P – III
35
3
C2
105
A6
P – II
30
1
C2
101
A2
P – II
30
2
C3
106
A7
P – IV
40
3
C3
107
A8
P – IV
40
2
C3
108
A9
P–I
20
1
33
C4 109 A10 Cyrix 20 2
Anomalies in 1NF Relation
• Insert anomalies:
• We cannot insert the information about the student until he joins any
course e.g. we cannot store information about the roll no 110 until he
join any course, similarly we are unable to store the information
about the course until there is a student who enroll into that course.
.
Anomalies in 1NF Relation
• Update anomalies:
• This relation is also susceptible to update anomalies because the
course in which a student studies may appear many times in the
table. If a teacher moves to another course, we are now faced with
two problems: we either search the entire table looking for that
teacher and update his or her course_code value or we miss one or
more tuples of that STUDENT and end up with an inconsistent
database. For small tables, this type of anomaly may not seem to be
much of a problem.
Anomalies in 1NF Relation
• Delete anomalies:
• This relation experiences deletion anomalies whenever we delete the last tuple of a
particular student. In this case, we not only delete the course information that connects
that student to a particular course, but also lose other information about the system on
which this student works.
• Let us consider, the case where we have to delete the information of student having
rollno 109, then we also lose the information about course_code C4 . Also if we have to
delete the information of java course we lose the information about the student Kumar.
•
Second Normal Form (2N
• A relation R is in 2NF if and only if it is in 1NF and every non-key
attribute is fully functional dependent on the primary key
• As per the Second Normal Form there must not be any partial
dependency of any column on primary key
• If we follow second normal form, then every non-prime attribute
should be fully functionally dependent on prime key attribute. That is,
if X → A holds, then there should not be any proper subset Y of X, for
which Y → A also holds true.
Example
We see here in Student_Project relation that the prime key attributes are
Stu_ID and Proj_ID. According to the rule, non-key attributes, i.e. Stu_Name
and Proj_Name must be dependent upon both and not on any of the prime
key attribute individually. But we find that Stu_Name can be identified by
Stu_ID and Proj_Name can be identified by Proj_ID independently. This is
called partial dependency, which is not allowed in Second Normal Form.
We broke the relation in two as depicted in
the above picture. So there exists no partial
dependency.
Third Normal Form
We find that in the above Student_detail relation, Stu_ID is the key and only prime key
attribute. We find that City can be identified by Stu_ID as well as Zip itself. Neither Zip is
a superkey nor is City a prime attribute. Additionally, Stu_ID → Zip → City, so there
exists transitive dependency.