5th Chap DBMS Notes
5th Chap DBMS Notes
Types of Normalization
) Second Normal form (2NE): Having unique values, no repeating groups, no partial dependency.
dependency.
) Third Normal form (3NF) : Same like second normal form and having transitive
moredeveloped version than 3NF.
49) Boyce-Codd Normal form (BCNF) : It is
dependency.
5) Fourth normal form (4NF) : No multi-valued
A 5.3.1 Need of Normalization
MAns. :
is not easy to manage database
operations like insertion,
process without Normalization, it
In database management
deletion, and modification without facing data loss problem.
Updation and Deletion Anomalies occur frequently. To understand need of
Insertion,
1 daabase is not normalized, then
normalization, first we should learn, what are Anomalies ?
Database
5.3.1(A) Anomalles
in DBMS.
GO. 6.3,5 Explain different anomalies
Ans.:
Anomalies are inconvenient or error-prone situation arising when we process the tables. There are three types Of
anomalies :
A) Insert Anomaly
into the database
An Insert Anomaly occurs when it is not possible to insert certain attributes without the
availability of other attributes.
For example, In College Database System, it is not possible to add entry of any new course unle any student
enrolled for it.
A domain is the set of all unique values which is permitted for an attribute. Atomic means that cannot be divided
further.
First Normal Form defines that all the attributes in a relation must have atomic (not further divisible) and single values.
Consider the table Course_details.
Table 5.4.1:Course_details
Category_id Category_name Languages
C_ PRG Programming C, VB, Java
C_SCR Scripting JavaScript, PHP, HTML
Table 5.4.1 is not in INF as the rule says "each attribute of a table must have atomic (single) values", thé attribute
'Languages' contain multiple values which violets the rule of INF. Toconvert this data into First Normal Form, we
have to rearrange it in the table.
Category_id Category_name Languages
C_PRG Programming C
C_PRG Programming VB
Java
C_PRG Programming
C_SCR Scripting JavaScript
C_SCR Scripting PHP
Now cach attribute contain single values. Hence the database design is in First Normal Fornm.
Database Manage
From STUDENT ID attribute it is possible to identify particular students' name. Name of the student is functionally
dependent on STUDENT_ ID and not vice versa; because more than two students may have same names and using
STUDENT Dwe can determine the name of student but using STUDENT_NAME we can't determine the appropriate
STUDENT_ID.
So we can say that,
STUDENT_ID ’ STUDENT_NAME
ie. STUDENT_NAME is functionally dependent on STUDENT_D
Similarly,
STUDENT _ID’ allthe attributes(i.e. ADDRESS, COURSE) !!"
So we can say that all the remaining attributes are functionally dependent on
STUDENT ID attribute.
It is possible that an attribute of a relation can be
identified by set of another attributes which are of the same relation.
This can be implies as follows :
STUDENT_ ID, STUDENT _NAME ’ ADDRESS
STUDENT _ID, STUDENT NAME ’ COURSE
In above situation, usually composite primary key
of relation is determinant in FD.
Databaso
M rageno. (5-11)
Functional Dependencies
5.4.1(A)Types of
64.3 Explaintypes offFunctional Dependency.
00.
MAns.:
types of Functional Dependency :
Followingareimportant
valued| FunctionalI Dependency (B) Multi-valued Functional Dependency
(A) Single-
Fully Functional | Dependency (D) Partial Functional
(C) Dependency
Transitive Functional Dependency (F) Trivial Functional
(E) Dependency
(G) Non Trivial Functional Dependency
Dependency
(A) Single-valued Functional
Datohace is a collection of related inforrnation in which information depends on another information.
The information is either single-valued or multi-valued. For example, the narme of the
perSOn or his / her date of
birh is single valued facts. But the Contact number of a person is a multi-valued attribute.
Asingle valued functional dependency is when A is the primary key of an
relation (e.g. STUDENT ID) andB is
ecingle valued attribute of the relation (e.g.
STUDENT _NAME). Then, A ’ B must always hold by the
relation.
STUDENT
M Ans.
Amulti-valued dependency exists when a relation R has at least 3 attributes (like A, Band C) and for value of Athere
iS a well defined set of values of B and a well defined set of values ofC. However, the set of values of Bis independent
of set C and více
versa.
For Example
Book
Table 5.4,3 Publlsbed
Prie
Auther Name
Book_Id
Jasmin 1000
B_001
980
B_002 Jasmin
1500
B_003 Smita
Smita 2000
B_004
determined by Book_Jd altribute,
AS Shown in Table 5.4.3, name of particular author s
(Book_ld) >>{Author_Name)
Also it is possible to determine the Price of book by Book_Id.
(Book_Id) ->> (Price)
But it is difficult to determine the price of book Using author name or vice versa. So this dependency is called ..
multi-valued functional dependency or simply multi-valued dependency.
(C) Fully Functional Dependency
Fully Functional Dependency occurs only in a relation with composite primary key. Fully functional dependerey
occurs when one or more non key attributes are depending on all parts of the composite primary key.
Table 5.4,4: Stud_Courses
Stud Id Stud_Name Contact No Course_Id Course Name Credit Hours Grade
1001 Jasmin 9950043321 C_310 Database Management Systern 3 A
1001 Jasmin 9950043321 C_420 Operating System 3 B
1002 Smita 9800678120 C_310 Database Management Systern 3 B
1002 Smita 9800678120 C_420 Operating System 3 B
1002 Smita 9800678120 C_422 Computer Network 3 C
1003 Rahul 8878712356 C_412 Software Engineering 3 A
Here the composite primary key is Stud _Id + Course_Id
Attribute Grade is fully functionally dependent on the
primary keys are needed to determine Grade.
primary key (Stud_Id, Course Jd) because both parts of
the
On the other hand both
Stud_Name, and Contact_No attributes are not fully
because only a part of the primary key namely functionally
Stud ld is needed to determine both Stud dependent the primary key,
on
Also attributes Credit-Hours and Name and Contact_No.
Course-Name
Course-Id isneeded to determine their values.
are not fully functionally
dependent on the primary key because only
Partial Functional Dependency occurs only in a relation with composite primary key. Partial
dendeny cus hen one or more non key attributes are depending on apart of the functional
primary key.
In partial functional dependency the determinant (Left-band side of FD) consists of key attributes, but not the
emtire primary key and the determined (Right-hand side of FD) consist of non-key attributes.
Freumpie,
Course Id
Here the composite primary key is Stud_Id +
Name Contsct_No Course Id Course Name Credit Hours Grade
Jasmin 9950043321 C_310 Database Management System 3
1001 A
Jasmin 9950043321 C_420 Operating System 3
2001 B
Smita 9800678 120 C_310 Database Management System 3 B
I002 Smita 9800678 120 C_420 Operating System 3 B
To ätemine name of the student or contact number of the student we can use only Stud_Id attribute which is part of
the primary key.
(Stad_Id) {Stud_ Name, Conatct_No}
E Transitive Functional Dependency
G0. 5A5 Describe the concept of transitive dependency.
Ans.:
Functional dependency is said to be transitive if it is indirectly form by using two functional dependencies.
- For example in relation R(A, B, C), Functional dependency F includes:
A’B and B’Cboth the FDs are hold by relation, and if B A doesn't hold
Then we can say that A’Calso holds by the relation.
This type of dependency is called as transitive dependency.
Erample
I Student_Courses relation holds
following FDs:
{Course _Id)’(Student_Name)
(Student Name)’(Student_Age)
e we can say that the relation also holds
following dependency.
(Counse ld)’(Student_Age)
(F) Trivial Functional
Dependency attributes is known as trivial functional dependency if the set of
The dependency of an attribute on a set of
attributes contains the
In this dependency theattribute
Right-Hand
itself. Side of FDis asubset of Left-Hand Side of the FD. Functional dependency of
Stud ld Name
Stud
1001 Jasmin
1002 Smita
1003 Rahul
(bud ld, Stud_Name} (Stud Id) is a trivial functional dependency as {Stud id} is subset of (Stud Id.
Stud_Name). By knowing the values of id and nanme of the student it is possible to find values of student id
uniquely.
The functional dependencies: olionannt
Stud_Id’ Stud Id and Stud Name ’ Stude_Name
is also referred as trivial dependencies.
It is inverse to trivial dependency. Functional Dependency is said to be non trivial if none of the attributes of
Right-Hand Side of FDs are part of the Left-Hand Side attributes.
Functional dependency of the form A’B is non-trivial if valuesin Bare not present in Aie. (B is not asubset
of A).
Non-Trivial Functional Dependency can be categorized into:
A) Armstrong's Axioms
UQ. 5.4.8 Write note on Armstrong's axioms. Ref. : (MU- Q. 6(b), May 18, 5 Marks);
Ans. :
Armstrong'saxioms were developed byWilliam W. Armstrong. These are a set of axioms (or inference rules) which
are used to infer (conclude) all the FDs on a relational database.
Consider a relation R having three sets of attributes X, Y,Z. Then the Armstrong's axioms are :
Reflexivity rule : If in a relation R values of Y attribute set are the subset of values in X attribute set, then
FD X’ Y can hold by the relation R. This type of dependency also called as trivial dependency.
Augmentation rule : If FD X’Y is hold by relation R, then FD XZ’ YZ also hold by relation.
R then the FD X’Z also
Transitivity rule :If Functional dependencies X’ Y and Y ’Z are hold by relation
dependency.
followed by relation R. This type of dependency also called as transitive
Properties of Armstrong's axioms
The Armstrong's Axioms are sound :
Armstrong's
Tunctional dependencies F on arelation R are given, then the FDs generated by using
c basie
axioms will hold by R.
which are previously defined will not generate invalid
ouer Words applying Armstrong axioms on set of FDs
FDs.
I in relation Rhaving three sets of attributes X, Y, Z, and the set of functional dependencies : X’ Yand X’ Zare
hold by relation R, then the functional dependency X’YZ also hold by relation R. This rule is called as union.
C) Decomposition or Projectivity
If in relationR having three sets of attributes X, Y, Zand the functional dependency X’ YZ is hold by relation Rthen
the following sets of Functional dependencies also hold by relation
R: X’Y and XZ
V Ans. :
One solution to eliminate the
redundancy and also the update and deletion
into two or more relations. This
process is called as decomposition. anomalies in database is breaking a relation
Let, R be a relation schema.
A
set of relation schemas (R1,
R2,..., Rn) is a decomposition of R if
R= RIU R2 ...U Rn
For example,
Let us know how to break the
relation into more than one relation.
Database
Ma
90
rCLASSINFO relation having COURSE_ID, COURSE_NAME, STUD _NAME, SUB_ID, and SUB_NAME.
Consider
Table 5.4.5:CLASSINFO
COURSE_D COURSE_NAME STUD_NAME SUB_ID SUB_NAME
C_101 F.E. Nishant S_112 C
C_102 S.E. Prashant S_212 Java
C_102 S. E. Prashant S_222 DBMS
SUBJECT_STUDENT as follows :
Now try to join these two relations COURSE_STUDENT and
Table 5.4.8: COURSE STUDENT SUBJECT STUDENT
COURSE ID COURSE NAME STUD NAME SUB D SUB NAME
F.E. Nishant S_112 C
C_101
S.E. Prashant S_212 Java
C_102
S. E. Prashant S_222 DBMS
C_102
T.E Sanvi S_311 VB
C_103
C_103 T.E Sanvi S_115 CPP
SO, to ensure that the database has g00d desion after decomposing:
the decomposition process S done through some
criteria which is defined by desirable propertics of decomposition.
2 5.4.2(A) Desirable Properties of Decompositions
Decompositon.
DQ. 5.4.10 Explain Lossless join Decomposition and Dependency Preservation
Ref.: (MU -Q. 1(b), May 17,5 Marks)
Ans. :
to hold so that the database remains in consistent state
Whle decomposing the relation there must be some pronerties
There are several properties which are required to hold while decomposing the database scnema.
i) Lossless decompositions
does not leads to any
When a relation is decomposed into several relations it is essential that the decomposition
loss of the information.
If there is the loss of the information, then it is called lossy decomposition or lossy-join decomposition.
Decomposition is called as lossless decomposition if there is no loss of information in the decomposition of the
relation into the desirable smaller relations. R(A,B,C)
Decomposition
A decomposition (R1, R2,..., Rn} of a relation R is called a lossless
decomposition for R if the natural join of R1, R2,..., Rn produces
R1(A, B) R2(A, C)
exactly the relation R.
R1 oR2 ’ R1, that is all attributes common to both RI and R2 functionally determine ALL the attributes in R1
OR
R1o R2> R2, that is all attributes common to both R1 and R2 functionally determine ALL the attributes in R2
In other words, if R1 o R2 forms a superkey of either R1 or R2. The
decomposition of R is a lossless
decomposition.
Dependency
i) D preservation decomposition
To ensure that the functional dependencies hold by relation R should also preserved by the smaller relauo
(RI, R2,.., Rn), the dependency preservation property of decomposition is used.
Adecomposition of the relation R into smaller relations R1, R2, .. Rn is dependency preserving 1au
Functional dependencies within R are followed in relations R1, R2, ., Rn.
Dependency preservation decomposition property
Dependency preservation decomposition is defined as, If R is a relation schema and F is a set of functioal
dependencies on R. R1, R2, ..., Rn form decomposition of R. If(F1 UF2 U... U Fn)" = F
Where,
Fl, F2, ... Fn are the functional dependencies of relation R1, R2, ..., Rn.
Fis a functional dependency of relation R.
(FlUF2 U... UFn)" is a closure of union of all sets of functional dependencies of R1, R2, ..Rn.
Fis a closure of set of functional dependency of relation R.
MAns. :
Tounderstand the second normal form first we should get concepts of Prime and Non-prime attributes.
Prime attribute : An attribute, which is a part of the prime-key is known as a prime attribute.
Non-prime attribute: An attribute, which is not a part of the prime-key is said to be a non-prime attribute.
As per the rule of Second Normal Form, every non-prime attribute must be dependent upon the prime attribute.
If we follow second normal form, then every non-prime attribute should be fully functionally dependent on prime key
attribute.
Toconvert the data in Second Normal Form we have to split the table in two diferent tables as follows.
STUDENT
In the table STUDENT all the non prime attributes like STU_NAME and PROJ_ NAME are completely depends upon
the prime attribute STUD_ID
PROJECT
PROJ_ID PROJ_NAME
P1 Banking System
P2 Library Management
P3 Speech to Text Converter
P4 ATM
In the table PROJECT the non prime attributes PROJ_NAME is completely depends upon the prime attribute PROJ_ID. R
UQ. 5.6.1 Explain 3NF. º Ref.: (MU -Q.3(b), May 15, Dec. 15, Q. 4{a), Dec. 16, May 18, Dec. 18, 2 Marks)
V Ans. :
Adatabase design is said to be in 3NF if both the following conditions are satisfied by it.
Initially the design must be in 2NF.
No non-prime attribute should be transitively dependent on prime key attribute.
For any non-trivial functional dependency, X’ A
Either X is a superkey or A is prime attribute.
Table 5.6.1 : STUDENT
STUD ID STU DETAILS
S101
NAME CITY ZIP
Kunal Pune 411037
S102
Radhika Nasik 422001
S103 Kiran Mumbai 400016
S104
Jay Nagpur 440001
In Table 5.6.1 the STUD Dis the only one
primary key. Here the data of city can be retrieved through
eTUD ID or ZIP code. But the CITY is not superkey as ciner
well as nor the CITY is prime attribute.
1Hare the CITY is depends upon ZIP and ZIP is
depends upon STUD_ID
Stud_id ’ zip ’ city.
This relationship is known as transitive dependency.
We have to remove this transitive dependency by implementing Third Normal Form. For this
purpose we have to splt
the STUDENT_DETAILS table in two different tables say
STUDENT DATA and CITY.
STUDENT DATA CITY
STUD D STU_NAME CITY
ZIP CITY
S101 Kunal Banking System 411037 Pune
S102 Radhika Library Management
422001 |Nasik
S103 Kiran Speech to Text Converter
400016 Mumbai
S104 Jay ATM
440001 Nagpur
Now the database design is converted into Third Normal Form. Here the basically design is already in Second Normal
Form and No non-prime attribute is transitively dependent on prime key attribute.
5.7 BOYCE-CODD NORMAL FORM (BCNF)
Ua. 5.7.1 Explain BCNF. Ret. (MU-a.3(b), May 15, Dec. 15, Q. 4(a), Dec. 16, May 18, 2Marks)
UQ. 5.7.2 Explain BCNF with example. Ref.: (MU -Q. 1(a), May 16, 5 Marks)
MAns. :
Adatabase design is said to be in BCNF if both the following conditions are satisfied by it.
Initially the table must be in 3NF.
For any non-trivial functional dependency X ’ A, Xmust be a super-key.
In above database design, Stud id is the super-key in the relation Student_Data and Zip is the super-key in the relation
City
Stu_ID ’ Stu_name, City
And Zip’ City
Which confirms that both the relations are in BCNF.
5.7.1 Difference between 3NF and BCNF
than 3NF ?
GQ 5.73 Differentiate between BCNE & 3NE. How it is stronger
Ans. :
BCNF
Sr. No. 3NF
Normal Forr
It stands for Third Normal Form. It stands for Boyce-Codd
Adatabase design should be already in 3NF to oDvert
2 Adatabase design should be already in 2NF to in BCNF.
convert in 3NF.
3. Rule : Rule:
dependency.
For any non-trivial functional dependency, X ’ A For any non-trivial functional
X’ A
Either
X is a superkey or
X must be a super-key.
Aisprime attribute
4 3NF is weaker than BCNF. BCNF is stronger than 3NF.
5. 3NF cannot catch all the anomalies. BCNF was developed to capture those anomalies that
could not be captured by 3NF.
6 More redundancy. Less redundancy.
7 Computational time is more. Computational time is less.
The above difference clearly indicates that BCNF is stronger than 3NE.
A 5.7.2 BCNF Decomposition Algorithm
GO. 5.74 Write BCNF Decomposition Algorithm.
VAns. :
Input :Arelation R and functional dependencies F which are hold on R.
Output : A decomposition of R into a set of relations (R1, R2,
R3,.., Rn), all of which are in BCNF.
1. If (R is in BCNF) then
Retum R.
2. Else If (there are BCNF
violation, let's consider one FD as X’Y) then
3 Begin
4. Compute X
5. Decompose R into (RI and R2)
Select RI=X., and let R2 have
inX* attributes X and those attributes of R which are not
6
Compute the sets of FDs S1 and S2 for R1 and
R2, respectively.
7. End
Repalstepsfon I to 5 forRI Iand R2 until all the relations (Ri) are in BCNF.
R
Retumthe union of the result of these compositions.
AampBe
Asfollows::Ifarelation R(A, B, C, D, E) and Functional dependency set Fcontains
A’BC
C->DE
F.
Step 1:Compute closure of
A+>ABCDE
B+’B
C+>CDE
D+>D
E+’E