0% found this document useful (0 votes)
100 views9 pages

Normal Forms 1 2 3 BCNF

The document discusses database normalization. It defines normalization as decomposing relations to reduce redundancy and ensure integrity. The objectives are to reduce redundancy, prevent information loss, and avoid inconsistencies when data is modified. First normal form requires each cell contain a single value. Normalization beyond first normal form relies on functional dependencies. Second normal form requires non-key attributes depend on the whole primary key. Third normal form eliminates transitive dependencies where a non-key attribute depends on another non-key attribute. Examples demonstrate decomposing relations in second and third normal form to eliminate redundancy.

Uploaded by

prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views9 pages

Normal Forms 1 2 3 BCNF

The document discusses database normalization. It defines normalization as decomposing relations to reduce redundancy and ensure integrity. The objectives are to reduce redundancy, prevent information loss, and avoid inconsistencies when data is modified. First normal form requires each cell contain a single value. Normalization beyond first normal form relies on functional dependencies. Second normal form requires non-key attributes depend on the whole primary key. Third normal form eliminates transitive dependencies where a non-key attribute depends on another non-key attribute. Examples demonstrate decomposing relations in second and third normal form to eliminate redundancy.

Uploaded by

prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

NORMALIZATION:

Def: Normalization is the process of decomposing a set of relations with anamolies to produce smaller and well
structured relations that contain minimum or no redundancy.

Def: Normalization is the process of reducing /decomposing a relation into a set of small relations free from data
redundancy and ensuring data integrity.

OBJECTIVES
The basic objective of normalization is to reduce the data redundancy and prevent loss of information or avoid
inconsistencies when the data base is altered.
The types of alterations needed for relations are:
1. Insertion of new data values to a relation.
2. Deletion of tuple or a row in a relation.
3. Updating or changing the value of an attribute in a tuple.
• The normalized relation does not include spurious information when the original schema is reconstructed.
• Preserves dependencies present in the original database

FIRST NORMAL FORM:


• First Normal Form (INF) deals with the shape of the record type.
• The relation is said to be in INF if and only if, it. It contains no repeating attributes or groups attributes.
• The relation is said to be INF if each cell value is atomic.

FUNCTIONAL DEPENDENCY:
Normalization beyond INF relies on functional dependency.

a. Full Functional dependency (FFD)

 The term ful functional dependency (FFD) is used to indicate the minimum set of attributes in a
determinant of a FD.
 In other words, the set of attributes X will be fully functionally dependent on the set of attributes Y if.
 X is functionally dependent on Y and
 X is not functionally dependent on any subset of Y Eg.

Note: Like FD, FFD is a property of the information presented by the relation.

 It is not an indication of the way that attributes are formed in to relations or current contents of
the relations.

b. FUNCTIONAL DEPENDENCY

 Normalization beyond INF relies on functional dependency.


 The value of an attribute in a raw will uniquely determine the value of another attribute.
 Let X and Y be two attributes of a relation. If there is only one attribute value of Y corresponding to it
for a given value of X, then Y is said to be functionally dependent on X.
 This is indicated by a relation X  Y.
 The arrow notation should be read as “Functionally determines”.
 So X functionally determines Y and X is functionally dependent on X.
Ex.: {Roll No} {Name} ≠ {Name} {Roll No}
Keys of relational schema:
A super key is a set of attributes S of a relation schema R i.e. SCR, with the property that no two tuples t1 and
t2 will have t1 [S]= t2 [S]
The difference between any key and a super key is that a key is minimal.
Ex. {EMPNPO} is a key for the relation EMP whereas {EMPNPO, ENAME} ,
{EMPNPO, ENAME, JOB} and any set of attributes is said to be a super key if it includes the key
{EMPNO}
Candidate key: The minimal super key is called the candidate key.
Primary Key: If a relation schema has more than one key, each is called a candidate key.

 One of the candidate key is choosen as primary key and others are secondary keys.
Prime attribute: An attribute of a relation schema R is called a prime attribute of R if it is a member of some
candidate key of R.
Non prime attribute: An attribute is called a non prime attribute if it is not a prime attribute i.e. an attribute is
said to be a non-prime attribute if it is not a part of the candidate keys.
Prove IR4 through IR8 by using IRI through IR3

SECOND NORMAL FORM:


2NF is more stringent normal form than 1 NF.
Def1: A relation is in 2NF if and only if, it is in INF and every non-key attribute is fully functionally dependent on
the whole key.
Def2: A relation schema R is in 2NF if every non prime attribute A in R is fully functionally dependent on the
primary key of R.
 2 NF is really a test of primary key.
 2 NF is concerned with the concept of full functional dependency.
 If a relation is in 1 NF and has a single attribute key it must automatically be in 2Nf.
Decomposing the relation:
As the table-2 for student relation involved redundancy and inconsistencies due to insertion, deletion &
updation. It can be decomposed in the three simple relations to eliminate the redundancy and inconsistency.
Stdinf (Roll no, name., dob) Courseinf
(subject, grade, rollno) Teacher inf (subject,
teacher)
Since, the dependencies in the student table are:

Roll No Name DOB Teacher Subject Grade

Stdinf
Roll No Name DOB
101 Rakesh 14.11.1985
102 Tapan 18.07.1986

103 Mohan 19.07.1985

Teacherinf

Subject Teacher

RDBMS Smith
DEC Johnes

MATH-II Allen

PHY-II Clark

NT Martin

Courseinf

Roll No Subject Grade


101 RDBMS E
101 DEC A

101 MATH-II O

101 PHY-II E

101 NT A

Second Normal Form (2NF)


Let us consider a relation schema R (A,B,C,D,E,F) with a set of functional dependencies.
F= {A} {B}
{A} {C}
{A} {F}
{A} {B}
{A,D} {F}
{D} {E}

(i) Find the scooper key

(ii) Closure
(iii) Identify the candidate key
(iv) IS it in 2NF ?
(v) If not decompose it in to 2 NF form. Solution: The given
functional Dependencies are:
{A} {B}, {A} {C}, {D} {E}, {AD} {F}
Super key of R is {AD}
Closure A+ = {A,B,C}
D+= {D,E}
{A,D} + = {A,B,C,D,E,F}
 There is no such single key that can derive /determine the other attribute.
 Here we take two keys together i.e. {AD} as the minimum super key. Hence the
candidate key is {AD}.

The relation is not is 2 NF since partial dependency exits.


{A, D} {B} partially dependency
{A, D} {C}
{A,D} {F} Full functional dependency
{A,D} {E} partial dependency
So we decompose our original relations R1 (A,D,F)
Since {A,D} {F}
R2 (A,B,C) Since {A} {B}, {A} {C}
R3 (D,E) Since {D} {E}
Example:
Let us consider the relation student (Roll No, Name, Address , courseno, cousename, grade)
Roll No Name Address Courseno Coursename Grade

{RollNo} {Name}
{Roll No} {Address}
{Course no} {Course name}
{Roll No, Course no} {Grade}

Problems

(1) IF we want to insert a new course then it can’t be inserted unless a new student roll no, is created.
(2) If we delete a student roll no, the subject or course information is deleted if the course in taken by
only student.
(3) If we update a name, address it has to be updated at many places.
(4) redundancy exist at many places.
So, we decompose the relation student into subrelators as: Student (roll no, name, address, courseno, coursename,
grade)

Stdinfor (Roll no, name, address) = R1 (A,B,C)


Grade course infor (Rollno, courseno, grade) = R2 (A,D,F) Course infor
(Courseno, coursename) = R3 (D,E)
(Student (rollno, name, address, courseno, coursename, grade)

R (A,B,C,D,E,F)

R1 (A,B,C) R2 (A,D,F) R2 (D,E)


(Rollno, name, address) (rollno, couseno, grade) (courseno, coursename)
THIRD NORMAL FORM (3NF)

 3NF is more stricter normal form than the 2NF


 3NF is concerned with transitive functional dependency.
 Transitive functional dependency may exist, only if there are more than one non key field.
 We may say that if a relation is in 2NF and has zero or one non key field it must automatically be in
3NF
Defintion1: A relation is said to be in 3NF when it is in 2NF and every non key attributes is functionally
dependent only on the primary key.
Definition2:
A relation is in 3NF if and only if it is in 2NF and there are no transitive functional dependency.
 Transitive functional dependency arises when one non key attribute is functionally
dependent on another non key attribute .
 In other words, the value of one non key attribute is determined by the value of another non key
attribute.
 This means there is redundancy in the database.
 Let us consider a relation employee (proj.no, manager, address)

Proj.no Manager Address

P1 Black, B 32, High Street

P2 Smith, J 11, New street


P3 Black, B 32 High street

P4 Black,B 32 High street

P5 Thomas,J 69 Black street

 Here transitive dependency exists, as proj. no determines manager and manager determines address.
 If a manager is associated with more than one project then his address is repeated leading to
data redundancy.
 If we need to change address of a manager we need to change at many places leading to updation
anomalies.
 So, we split the table in to two relations.
 The determinant attributes become the primary key in the new relation
 The attribute manager becomes the link between two tables/new relations.
Project

Proj.no Manager

P1 Black, B
P2 Smith, J

P3 Black, B

P4 Black,B
P5 Thomas,J

Manager

Manager Address

Black, B 32, High Street


Smith, J 11, New street
Thomas,J 69, Back street

 Here in project relation , proj.no serves as the primary key and manager can be determined by project
no.
 In manager relation, address can be determined by knowing the manager name, so, manager becomes the
primary key.
 So, in the above relation the non prime attributes depend upon the primary key.
 Hence we can define the third normal form as below

Guidelines for converting a table to 3NF:

 Find the non. key attributes and remove them that are functionally dependent on attributes that are not
the primary key.
 Place them in a different relation.
Third Normal Form (3NF) (Summary)
A relation R is said to be in third normal form (3NF) if the relation R is in 2NF and non- prime attributes are:
 Mutually independent
 Functionally dependent on the primary key
 In other words, no attributes of the relation should be transitively dependent on the primary key.
 Thus in 3NF, no non prime attribute is functionally dependent on another non- prime attribute.
 This means that a relation in 3NF consists of the primary key and a set of independent non
prime attributes.
Summary of Normal Forms

1NF Relation should have no non atomic Forms new relations for each non atomic
attributes attribute or rested relations.

2NF For relations where primary key contains Decompose and set up a new relation for each partial
multiple attribute s no non key attribute should be
key with its dependent attribute(s) make sure to keep a
functionally dependent on a primary key.
relation with the original primary key and any
attributes that are fully functionally
dependent onit.
3NF A relation should have a nonkey attribute Decompose and set up a relation that includes the non
functionally determined by another nonkey key attribute(s) that functionally determine (s) other
non key attributes.
attribute (or by a set of non key attributes)
.That is , there should be no transitive
dependency of non key attribute on the
primary key.

Third normal form (3Nf) contd.


Definition: A Relation is in if and only if it is in 2NF and for any non trivial functional dependency.
X Y

(i) Either X is the super key or


(ii) Y to be a prime attribute
Example: Let us consider a relation R (A,B,C,D) With functional dependencies {A} {B} , {A} {C}
And {C} {D} .Determine the candidate key and normalize upto 3NF.

Solution: Functional Dependencies are:


Here {A} {B}
{A} {C}
{C} {D}
The closure of C =C+ = {C, D}
The closure of A =A+ = {A, B, C, D}
So, A is the candidate key. Since the key determine the non key attributes it is in 2NF.
Since there exist transitive dependencies {A} {C} and {C} {D}. So, we decompose, the relation into
two relations
R1 (A, B, C) Since {A B, A C}

R (A,B,C,D)

R2 (C, D) Since { C D}

Lossless join and Dependency preserving Decomposition.


A relation schema R can be decomposed in to collection of relation schemes to eliminate some of the
anomalies contained in the original relation scheme R.
However the decomposition should be maintened with
(i) No loss of information
(ii) Dependency preserved
(iii) Attribute preserved.
To main ten the above properties we check the following.
(i) Lossless join decomposition
(ii) Dependency preserving
(iii) Attribute preserving
Lossless join decomposition
A decomposition of a relation scheme R <S,F> in to the relation schemes, Ri (1≤ i≤ n) is said to be lossless join
decomposition or simply lossless if for every relation R (R) that satisfies the FDS in F, the natural join of the
projections of R gives the original relation
R. is R = π R1 (R) X π R1 (R) X X π Rn (R)

If RC = π R1 (R) X π R1 (R) X................................X π Rn (R) then the decomposition is called lossy.

BCNF:
Def1: A relation is said to be in BCNF if and only if every determinant is a candidate key. Def: A relation is said
to be in BCNF if and only if it is in 3NF or 2NF and for every non trivial functional dependency XY.
(i) X is a super key

(ii) Y to be the prime attribute X to be super key.


Def2: A relation schema R is in BCNF with respect to a set for functional dependencies, if for all FDS in .
F+ X Y at least one of the following is true.

(i) X Y is trivial or

(ii) X is a super key


EX: R (A,B,C) is the given relation schema and the given Functional Dependency is
F ={A B, B C}
Solution: Key = {A} since A+ = {A,B,C}
R is not in BCNF as B is not a super key.
Decomposition:
R (ABC)

R1 (A,B) R2 (B,C)
Now R1 and R2 in BCNF
The decomposition is lossless and dependency preserving.
Boyce Code Normal Form (BCNF)

 To eliminate the problems and redundancy of 3NF. Boyce proposed a normal form known as Boyee
code Normal form (BCNF).
 When the relation has more than one candidate key anamolies may arise even though the relation is in
3NF.
 3NF does not deal with the case of a relation with overlapping candidate keys.
 BCNF is based on the concept of a determinant
 A determinant is any attribute(s) on which some other attributes is fully functionally dependent.

Comparison of 3NF and BCNF:

 BCNF is stronger than 3NF


 The relations there in 3NF are not necessarily in BCNF
 BCNF is needed in certain situations to obtain full under standing of the data model.
 There are several routes to take to arrive at the same set of relations in BCNF.
Difference: The difference between 3NF and BCNF is that for a functional dependency AB, 3NF allows this
dependency in a relation if B is a primary key attribute and A is not a candidate key.
Whereas, BCNF insists that for this dependency to remain in this relation, A must be candidate key.
Therefore, BCNF is a stronger form of 3NF, such that every relation in BCNF is also in 3NF.
Example: Let us consider a relation R (A,B,C) with the set of functional dependencies.
F = {A,B} {C} or {A} {B}, {B} {C}
{C} {B}.
Solution: {A,B} + = {A,B,C}
Here, {A,B} is the candidate key, since there is no such single key for deriving all the non key attributes. So
we take the minimal super key {A,B} as the candidate key.
The relation is not is BCNF since {C} is not the .
Decomposition for BCNF:
The relation R (A,B,C) can be decomposed in toe R1 (A,C) and R2 (B,C)

R (A,B,C)

R1 (A,C) R2 (B,C)

Design goals of relational database design.


There are three important design goals
(i) BCNF
(ii) Loss less join
(iii) Dependency preservation
If we can’t achieve all these three, we accept
(i) 3NF
(ii) Loss less join
(iii) Dependency preservation

You might also like