E-Content - Dbms - Unit - 4
E-Content - Dbms - Unit - 4
Figure 4.1
4.2 Problems caused by Redundancy:
4.2.1. Data Inconsistency
4.2.2. Memory Fragmentation
4.2.3. Anomalies:
There are three types of anomalies:
i. update,
ii. deletion and
iii. insertion anomalies.
Let us consider an example :
Each employee in a company has a department associated with them as well as the student
group they participate in.
Employee_ID Name Department Student_Group
123 James Accounting Pst club
234 B. Rech Marketing Marketing Club
234 B. Rech Marketing Management Club
456 Anand CIS Technology Org.
456 Anand CIS Pst club
4.6 Normalization:
Normalization is a relational database management system design concept which is a process of
designing the database structure such that it minimizes the data redundancy and also data anomalies.
The process of normalization includes a series of stages known as Normal Forms. Normalization
rules are divided into following normal form :
1. First Normal Form (1 NF)
2. Second Normal Form (2 NF)
3. Third Normal Form (3 NF)
4. Boyce-Codd Normal Form (BCNF)
4.6.1 First Normal Form (1 NF) :
A relation is in first Normal Form if and only if all underlying domains contain atomic values only.
In other words, a relation doesn’t have multivalve attributes.
For example:
Consider a STUDENT (Sid, Sname, Cname) relation.
Student :
S1 A C,C++
Due to occurrence of MVA, the above relation is not in 1
⇐
S2 B C++,DB NF.
S3 A DB
Student :
S1 A C
S1 A C++
⇐ The relation is in 1NF
S2 B C++
S2 B DB
S3 A DB
Partial Dependency :
Student :
S1 A C
S1 A C++
S2 B C++
S2 B DB
S3 A DB Partial Dependencies :
SID → Sname {as SID is a Proper Subset of
{SID,Cname} : Primary Key
Candidate Key {SID,Cname}.
Functional Dependencies:
{SID,Cname} → Sname
SID → Sname
R2 :
Transitive Dependency
Example of 3NF :
Let us consider the relation Sup_City(SID, Status, City) :
Sup_City :
S1 30 Delhi
S2 10 Karnal
S3 40 Rohtak
S4 30 Delhi
Solution :
Removal of Transitive Dependency by creating separate table
⇓
SC :
CS :
SID City
City Status
S1 Delhi
Delhi 30
S2 Karnal
Karnal 10
S3 Rohtak
Rohtak 40
S4 Delhi
City : Primary Key
SID : Primary Key
The relations SC and CS are in 3NF as they doesn't contain any transitive dependencies.
4.6.4 BCNF – Boyce Codd Normal Form:
Let R be the relational schema, R is in BCNF only if :
R should be in 3NF.
Every Functional Dependency will have a Superkey on the LHS or all determinants are the
superkeys.
Example :
Consider the following relationship R(ABCD) having following functional dependencies:
F = {A → BCD, BC → AD, D → B}
Functional
Is FD in BCNF or not ? Reason ?
Dependency
1 C1/C2 B1/B2
2 C1 B1
3. It may preserve all the dependencies It may not preserve the dependencies.
Decomposition:
Decomposition is the process of dividing longer relations into smaller relations. This division is
based on functional and other dependencies which are specified by database designer.
The decomposition of a relation scheme R consists of replacing the relation schema by two or more
relation schemas that each contain a subset of the attributes of R and together include all attributes in
R.
Problems related to Decomposition:
Decomposing a relation schema can create more problems unless we handle them carefully.
Two important questions must be avoided repeatedly.They are:
1. Do we need to decompose a relation ?
2. What problems does a given decomposition cause ?
To answer the first question, several normal forms have been proposed for relations. If a
relation schema is in one of these normal forms, we know that certain kinds of problems
cannot arise.
To answer the second question, two properties of decomposition arte of particular
interest :
1. Loss-less join decomposition
2. Dependency Preserving Decomposition
STUDENT:
No_name:
Roll_no Sname
111 parimal
Sname Dept
parimal COMPUTER
parimal ELECTRICAL
222 parimal
Name_dept :
In lossy decomposition ,spurious tuples are generated when a natural join is applied to the relations in
the decomposition.
stu_joined :
Stu_name: Stu_dept :
Now , when these two relations are joined on the common column 'roll_no' ,the resultant relation will
look like stu_joined.
stu_joined :
In lossless decomposition, no any spurious tuples are generated when a natural joined is applied to the
relations in the decomposition.
Example 2 :
Let R(ABCDEF) F = {A → B, B → C, C → D, E → F} decomposed into D = R1(AB), R2(BCD), R3(DEF).
Find whether D is Lossless or Lossy ?
Solution :
Step 1:
AB ∪ BCD ∪ DEF = ABCDEF = R // Condition 1 satisfies
step 2:
AB ∩ BCD = B
B+ = {BCD} //superkey of R2
⇒ R12(ABCD)
ABCD ∩ DEF = D
D+ = {D} // Not a superkey of R12 or R3
Therfore, the given decomposition is Lossy.
closure(A) = { A } // Trivial
closure(B) = { B } // Trivial
closure(C) = {C, A, D} but D can't be in closure as D is not present R1.
= {C, A}
C--> A // Removing C from right side as it is trivial attribute
closure(AC) = {A, C, D}
AC --> D // Removing AC from right side as these are trivial attributes
TEXT BOOK:
1. Raghurama Krishnan, Johannes Gehrke, Database Management Systems, 3 rd Edition, TATA
McGraw hill.
2. Web pages