0% found this document useful (0 votes)
9 views15 pages

UNIT II DBMS MCA 23

ascaxca

Uploaded by

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

UNIT II DBMS MCA 23

ascaxca

Uploaded by

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

UNIT II

Contents………………………… Page No
Functional Dependencies and Normalization for Relational Databases
1. Informal Design Guidelines for Relation Schemas 1
2. Functional Dependencies 3
3. 1NF (First Normal Form) 4
4. 2NF (Second Normal Form) 5
5. 3NF (Third Normal Form) 6
6. BCNF (Boyce-Codd Normal Form) 6
Relational Database Design Algorithms and Further Dependencies
7. Properties of Relational Decompositions 7
8. Multivalued dependencies and fourth normal form 9
9. Join Dependencies and Fifth Normal Form 11

0
FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL
DATABASES
1. INFORMAL DESIGN GUIDELINES FOR RELATION SCHEMAS

1
2
2. FUNCTIONAL DEPENDENCIES

3
3. FIRST NORMAL FORM (1NF)
Normalization is a technique for dividing relation into relations and identifying anomalies
in the existing relations.
Advantages of Normalization:
 Less storage space
 Reduces data redundancy in a database
 It eliminates serious manipulation anomalies.

4
First Normal Form (1NF):
A relation in which the intersection of each row and column contains one and only one
value.Example:
EmpNum EmpPhone EmpDegrees
111 040-23840112
222 040-23987654 { BA, BSc, PhD }
333 040-23456789 { BSc, MSc }
Transformation into 1NF:
Employee( EmpNum, EmpPhone) EmployeeDegree(EmpNum, EmpDegrees)
EmpNum EmpPhone EmpNum EmpDegrees
111 040-23840112 222 BA
222 040-23987654 222 BSc
333 040-23456789 222 PhD
333 BSc
333 MSc

4. SECOND NORMAL FORM (2NF)


Partial Dependency: A partial dependency exists when an attribute B is functionally dependent
on an attribute A, and A is a component of a multipart candidate key.
2NF: A relation is in 2NF if it is in 1NF, and every non-key attribute is fully dependent on each
candidate key. (That is, we don’t have any partial functional dependency.)
A relation in 2NF will not have any partial dependencies.

Example: Consider this InvLine table (in 1NF):


InvNum LineNum ProdNum Qty InvDate
Transformation into 2NF:
We can improve the database by decomposing the above relation into relations:
InvNum LineNum ProdNum Qty

InvNum InvDate

5
5. THIRD NORMAL FORM (3NF)
Transitive dependency: A condition where A, B, and C are attributes of a relation such that if
A →B and B→C, then C is transitively dependent on A via B.
A relation is in third normal form, if there is no transitive dependency for non-prime attributes as
well as it is in second normal form.

A relation is in 3NF if at least one of the following condition holds in every non-trivial function
dependency X –> Y:

1. X is a super key.
2. Y is a prime attribute (each element of Y is part of some candidate key).
In other words,

A relation that is in First and Second Normal Form and in which no non-primary-key attribute is
transitively dependent on the primary key, then it is in Third Normal Form (3NF).

Note – If A->B and B->C are two FDs then A->C is called transitive dependency.
The normalization of 2NF relations to 3NF involves the removal of transitive dependencies. If a
transitive dependency exists, we remove the transitively dependent attribute(s) from the relation
by placing the attribute(s) in a new relation along with a copy of the determinant.

Example:Consider an Employee relation:


EmpNum EmpName DeptNum DeptName
. Transformation into 3NF:
EmpNum EmpName DeptNum DeptNum DeptName

6. BOYCE-CODD NORMAL FORM (BCNF)


Stronger than 3NF
Determinant: Refers to the attribute or group of attributes on the left hand side of the arrow of a
functional dependency.
Ex: Consider an FD, EmpNum→EmpEmail. Here, EmpNum is a determinant of EmpEmail.
BCNF: A relation is in BCNF, if and only if, every determinant is a candidate key.

6
Example:

Transformation into BCNF:

Note: any relation that is in BCNF, is in 3NF The First Normal Form -The Second Normal Form
- The Third Normal Form - Boyce Codd Normal Form –

RELATIONAL DATABASE DESIGN ALGORITHMS AND FURTHER


DEPENDENCIES
7. PROPERTIES OF RELATIONAL DECOMPOSITIONS
When a relation in the relational model is not appropriate normal form then the decomposition of a
relation is required. In a database, breaking down the table into multiple tables termed as
decomposition. The properties of a relational decomposition are listed below :

1. Attribute Preservation:
Using functional dependencies the algorithms decompose the universal relation schema R in a set of
relation schemas D = { R1, R2, ….. Rn } relational database schema, where ‘D’ is called the
Decomposition of R.
The attributes in R will appear in at least one relation schema Ri in the decomposition, i.e., no
attribute is lost. This is called the Attribute Preservation condition of decomposition.

7
2. Dependency Preserving
If each functional dependency X->Y specified in F appears directly in one of the relation schemas
Ri in the decomposition D or could be inferred from the dependencies that appear in some Ri. This
is the Dependency Preservation.
3. If a decomposition is not dependency preserving some dependency is lost in decomposition. To
check this condition, take the JOIN of 2 or more relations in the decomposition.

For example:
R = (A, B, C)
F = {A ->B, B->C}
Key = {A}
R is not in BCNF.

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

R1 and R2 are in BCNF, Lossless-join decomposition, Dependency preserving.


Each Functional Dependency specified in F either appears directly in one of the relations in the
decomposition.
It is not necessary that all dependencies from the relation R appear in some relation Ri.
It is sufficient that the union of the dependencies on all the relations Ri be equivalent to the
dependencies on R.

3. Non Additive Join Property


Another property of decomposition is that D should possess is the Non Additive Join Property,
which ensures that no spurious tuples are generated when a NATURAL JOIN operation is applied
to the relations resulting from the decomposition.
4. No Redundancy
Decomposition is used to eliminate some of the problems of bad design like anomalies,
inconsistencies, and redundancy.If the relation has no proper decomposition, then it may lead to
problems like loss of information.
5. Lossless Join :
Lossless join property is a feature of decomposition supported by normalization. It is the ability to
ensure that any instance of the original relation can be identified from corresponding instances in
the smaller relations.
For example:
R : relation, F : set of functional dependencies on R,

8
X, Y : decomposition of R,
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 exactly the relation R.

A decomposition is lossless if we can recover:


R(A, B, C) -> Decompose -> R1(A, B) R2(A, C) -> Recover -> R’(A, B, C)
Thus, R’ = R
Decomposition is lossless if:
X intersection Y -> X, that is: all attributes common to both X and Y functionally determine ALL
the attributes in X.
X intersection Y -> Y, that is: all attributes common to both X and Y functionally determine ALL
the attributes in Y
If X intersection Y forms a superkey of either X or Y, the decomposition of R is a lossless
decomposition.

8. MULTIVALUED DEPENDENCIES AND FOURTH NORMAL FORM


 If two or more independent relations are kept in a single relation or we can say multivalue
dependency occurs when the presence of one or more rows in a table implies the presence of
one or more other rows in that same table. Put another way, two attributes (or columns) in a
table are independent of one another, but both depend on a third attribute. A multivalued
dependency always requires at least three attributes because it consists of at least two
attributes that are dependent on a third.
 For a dependency A -> B, if for a single value of A, multiple values of B exist, then the table
may have a multi-valued dependency. The table should have at least 3 attributes and B and C
should be independent for A ->> B multivalued dependency.

Example :

Person Mobile Food_Likes

Mahesh 9893/9424 Burger/Pizza

Ramesh 9191 Pizza

Person->-> mobile,
Person ->-> food_likes

9
This is read as “person multi determines mobile” and “person multi determines food_likes.”
Note that a functional dependency is a special case of multivalued dependency. In a functional
dependency X -> Y, every x determines exactly one y, never more than one.

Fourth Normal Form (4NF)


The Fourth Normal Form (4NF) is a level of database normalization where there are no non-trivial
multivalued dependencies other than a candidate key. It builds on the first three normal forms (1NF,
2NF, and 3NF) and the Boyce-Codd Normal Form (BCNF). It states that, in addition to a database
meeting the requirements of BCNF, it must not contain more than one multivalued dependency.
Properties
A relation R is in 4NF if and only if the following conditions are satisfied:
1. It should be in the Boyce-Codd Normal Form (BCNF).
2. The table should not have any Multi-valued Dependency.
A table with a multivalued dependency violates the normalization standard of the Fourth
Normal Form (4NF) because it creates unnecessary redundancies and can contribute to inconsistent
data. To bring this up to 4NF, it is necessary to break this information into two tables.

Example: Consider the database table of a class that has two relations R1 contains student ID(SID)
and student name (SNAME) and R2 contains course id(CID) and course name (CNAME).
Table R1

SID SNAME

S1 A

S2 B

Table R2
CID CNAME

C1 C

C2 D

When their cross-product is done it resulted in multivalued dependencies.

10
Table R1 X R2
SID SNAME CID CNAME

S1 A C1 C

S1 A C2 D

S2 B C1 C

S2 B C2 D

Multivalued dependencies (MVD) are:


SID->->CID; SID->->CNAME; SNAME->->CNAME
9. JOIN DEPENDENCIES AND FIFTH NORMAL FORM
Joint Dependency
Join decomposition is a further generalization of Multivalued dependencies. If the join of R1
and R2 over C is equal to relation R then we can say that a join dependency (JD) exists, where R1
and R2 are the decomposition R1(A, B, C) and R2(C, D) of a given relations R (A, B, C, D).
Alternatively, R1 and R2 are a lossless decomposition of R. A JD ⋈ {R1, R2, …, Rn} is said to
hold over a relation R if R1, R2, ….., Rn is a lossless-join decomposition. The *(A, B, C, D), (C,
D) will be a JD of R if the join of joins attribute is equal to the relation R. Here, *(R1, R2, R3) is
used to indicate that relation R1, R2, R3 and so on are a JD of R. Let R is a relation schema R1,
R2, R3……..Rn be the decomposition of R. r( R ) is said to satisfy join dependency if and only if

Joint Dependency
Example: Table1
Company Product

C1 Pendrive

C1 mic

C2 speaker

C2 speaker

11
Company->->Product

Table R2

Agent Company

Aman C1

Aman C2

Mohan C1

Agent->->Company

Table R3

Agent Product

Aman Pendrive

Aman Mic

Aman speaker

Mohan speaker

Agent->->Product

Table R1⋈R2⋈R3

Company Product Agent

C1 Pendrive Aman

C1 mic Aman

C2 speaker speaker

C1 speaker Aman

Agent->->Product

12
Fifth Normal Form / Projected Normal Form (5NF)
A relation R is in Fifth Normal Form if and only if everyone joins dependency in R is implied by
the candidate keys of R. A relation decomposed into two relations must have lossless
join Property, which ensures that no spurious or extra tuples are generated when relations are
reunited through a natural join.
Properties
A relation R is in 5NF if and only if it satisfies the following conditions:
R should be already in 4NF.
It cannot be further non loss decomposed (join dependency).
Example – Consider the above schema, with a case as “if a company makes a product and an
agent is an agent for that company, then he always sells that product for the company”. Under
these circumstances, the ACP table is shown as:
Table ACP
Agent Company Product

A1 PQR Nut

A1 PQR Bolt

A1 XYZ Nut

A1 XYZ Bolt

A2 PQR Nut

The relation ACP is again decomposed into 3 relations. Now, the natural Join of all three relations
will be shown as:
Table R1
Agent Company

A1 PQR

A1 XYZ

A2 PQR

13
Table R2

Agent Product

A1 Nut

A1 Bolt

A2 Nut

Table R3

Company Product

PQR Nut

PQR Bolt

XYZ Nut

XYZ Bolt

The result of the Natural Join of R1 and R3 over ‘Company’ and then the Natural Join of R13 and
R2 over ‘Agent’and ‘Product’ will be Table ACP.
Hence, in this example, all the redundancies are eliminated, and the decomposition of ACP is a
lossless join decomposition. Therefore, the relation is in 5NF as it does not violate the property
of lossless join.

14

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy