DBMS R19 - Unit-4
DBMS R19 - Unit-4
Satyanarayana Reddy
Unit – IV
SCHEMA REFINEMENT (NORMALIZATION) : Purpose of Normalization or schema refinement, concept
of functional dependency, normal forms based on functional dependency(1NF, 2NF and 3 NF), concept of
surrogate key, Boyce-codd normal form(BCNF), Lossless join and dependency preserving decomposition,
Fourth normal form(4NF).
Updation Anamoly : If data items are scattered and are not linked to each other properly, then it could
lead to strange situations. For example, when we try to update one data item having its copies scattered
over several places, a few instances get updated properly while a few others are left with old values.
Such instances leave the database in an inconsistent state.
Example: To update address of a student who occurs twice or more than twice in a table, we will have
to update S_Address column in all the rows, else data will become inconsistent.
Insertion Anamoly : We tried to insert data in a record that does not exist at all.
Example: Suppose for a new admission, we have a Student id(S_id), name and address of a student but
if student has not opted for any subjects yet then we have to insert NULL there, leading to Insertion
Anamoly.
Deletion Anamoly : We tried to delete a record, but parts of it was left undeleted because of
unawareness, the data is also saved somewhere else.
Example: If (S_id) 402 has only one subject and temporarily he drops it, when we delete that row,
entire student record will be deleted along with it.
1
www.Jntufastupdates.com 1
Database Management Systems Prof. B. Satyanarayana Reddy
ARMSTRONG'S AXIOMS
If F is a set of functional dependencies then the closure of F, denoted as F+, is the set of all functional
dependencies logically implied by F. Armstrong's Axioms are a set of rules, that when applied repeatedly,
generates a closure of functional dependencies.
Reflexive rule − If alpha is a set of attributes and beta is_subset_of alpha, then alpha holds beta.
Augmentation rule − If a → b holds and y is attribute set, then ay → by also holds. That is adding
attributes in dependencies, does not change the basic dependencies.
Transitivity rule − Same as transitive rule in algebra, if a → b holds and b → c holds, then a → c also
holds. a → b is called as a functionally that determines b.
3.Transitivity: IF X→Y and Y→Z are two functional dependencies then by transitivity, X→Z is also a
functional dependency.
4. Union: If X→Y and X→Z are two functional dependencies then, X→YZ is also a functional dependency.
5. Decomposition: If X→YZ is a functional dependency then X→Y and X→Z are also functional
dependencies.
2
www.Jntufastupdates.com 2
Database Management Systems Prof. B. Satyanarayana Reddy
Identifying keys in the given relation based on Functional Dependencies associated with it
X+ is a set of attributes that can be determined using the given set X of attributes.
If X+ contains all the attributes of a relation, then X is called "Super key" of that relation.
If X+ is minimal set, then X is called "Candidate Key" of that relation.
If no closure contains all the elements then in such a case we can find independent attributes of that
relation i.e., the attributes that which are not in the R.H.S. of any dependency. If the closure of the Independent
attributes contains all the elements then it can be treated as a candidate key.
If the closure of independent attributes also doesn't contain all the elements then we try to find the key
by adding dependent attributes one by one. If we couldn't find key then we can add groups of dependent
attributes till we find a key to that relation.
3
www.Jntufastupdates.com 3
Database Management Systems Prof. B. Satyanarayana Reddy
P2 D4 15 Raj
The above relation is in 1NF but not in 2NF. Key for the relation is Patient No. and Drug. After
eliminating the Partial functional dependencies, the decomposed relations are:
Patient Parent Relation Dependencies
Patient No. Pname
P1 Kiran Key: Patient No. Patient No. → Pname
P2 Raj
The above 2 relations satisfy 2NF. They don't have partial functional dependencies.
Note: If key is only one attribute then the relation is always in 2NF.
4
www.Jntufastupdates.com 4
Database Management Systems Prof. B. Satyanarayana Reddy
Ward No. → Ward Name is transitive because Ward No. is not a key. To make this relation satisfy 3NF
transitive dependency must be removed from it. It can be done by decomposing the relation. The decomposed
relations are as follows:
Ward Key Dependencies
Ward No. Ward Name
W1 ICU Ward No. Ward No. → Ward Name
W2 General
The above two relations satisfy 3NF. They don't have transitive dependencies.
Note 1: A relation R is said to be in 3NF if whenever a non trivial functional dependency of the form X → A
holds then either X is a super key or A is a prime attribute.
Note 2: If all attributes are prime attributes then the relation is in 3NFbecause with such attributes no partial
functional dependencies and transitive dependencies exists.
5
www.Jntufastupdates.com 5
Database Management Systems Prof. B. Satyanarayana Reddy
The given relation is in 3NF. Observe, however, that the names of Dept. and Head of Dept. are
duplicated. Further, if Professor P2 resigns, rows 3 and 4 are deleted. We lose the information that Rao is the
Head of Department of Chemistry.
The normalization of the relation is done by creating a new relation for Dept. and Head of Dept. and deleting
Head of Dept. form the given relation. The normalized relations are shown in the following.
6
www.Jntufastupdates.com 6
Database Management Systems Prof. B. Satyanarayana Reddy
Professor_work Dependencies
Professor Code Department Percent Time Department,Professor Code → Percent time
P1 Physics 50
P1 Mathematics 50 Department is foreign key referring
Department in the Deartment_Details relation
P2 Chemistry 25
P2 Physics 75
P3 Mathematics 100
Depatrment_Details Dependencies
Department Head of Dept. Department → Head of the Department
Physics Ghosh
Mathematics Krishnan
Chemistry Rao
7
www.Jntufastupdates.com 7
Database Management Systems Prof. B. Satyanarayana Reddy
Vendor_Supply Vendor_Project
Vendor Code Item Code Vendor Code Project No.
V1 I1 V1 P1
V1 I2 V1 P3
V2 I2 V2 P1
V2 I3 V3 P2
V3 I1 .
SUMMARY
Input Transformation Output
Relation Relation
All Relations Eliminate variable length record. Remove multi-attribute lines in table. 1NF
1NF Remove dependency of non-key attributes on part of a multi-attribute key. 2NF
2NF Remove dependency of non-key attributes on other non-key attributes. 3NF
3NF Remove dependency of an attribute of a multi attribute key on an attribute of BCNF
another (overlapping) multi-attribute key.
BCNF Remove more than one independent multi-valued dependency from relation 4NF
by splitting relation.
4NF Add one relation relating attributes with multi-valued dependency. 5NF
PROPERTIES OF DECOMPOSITION:
Every Decomposition must satisfy 2 properties.
1. Lossless join
2. Dependency Preserving
1. Lossless join:
If we decompose a relation R into relations R1 and R2,
Decomposition is lossy if R1 ⋈ R2 ⊃ R
Decomposition is lossless if R1 ⋈ R2 = R
To check for lossless join decomposition using FD set, following conditions must hold:
1. Union of Attributes of R1 and R2 must be equal to attribute of R. Each attribute of R must be either in R1
or in R2. Att(R1) U Att(R2)=Att(R)
8
www.Jntufastupdates.com 8
Database Management Systems Prof. B. Satyanarayana Reddy
For Example, A relation R (A, B, C, D) with FD set {A->BC} is decomposed into R1(ABC) and R2(AD) which
is a lossless join decomposition as:
1. First condition holds true as Att(R1) U Att(R2) = (ABC) U (AD) = (ABCD) = Att(R).
2. Second condition holds true as Att(R1) ∩ Att(R2) = (ABC) ∩ (AD) ≠ Φ
3. Third condition holds true as Att(R1) ∩ Att(R2) = A is a key of R1(ABC) because A->BC is given.
If we decompose a relation R into relations R1 and R2, All dependencies of R either must be a part of
R1 or R2 or must be derivable from combination of FD’s of R1 and R2.
For Example, A relation R (A, B, C, D) with FD set{A->BC} is decomposed into R1(ABC) and R2(AD)
which is dependency preserving because FD A->BC is a part of R1(ABC).
Decomposition of a relation is done when a relation in relational model is not in appropriate normal form.
Relation R is decomposed into two or more relations if decomposition is lossless join as well as dependency
preserving.
9
www.Jntufastupdates.com 9