0% found this document useful (0 votes)
13 views

UNIT-3DBMS (Normalization and Functional Dependency)

The document discusses database design theory related to functional dependencies and normal forms. It covers topics such as functional dependencies, normal forms based on primary keys including first, second, third, and higher normal forms, and provides examples of applying these concepts. The goal of normalization is to minimize data redundancy and anomalies through a process of decomposing relations that do not satisfy certain normal form conditions.

Uploaded by

mysadidvd009
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

UNIT-3DBMS (Normalization and Functional Dependency)

The document discusses database design theory related to functional dependencies and normal forms. It covers topics such as functional dependencies, normal forms based on primary keys including first, second, third, and higher normal forms, and provides examples of applying these concepts. The goal of normalization is to minimize data redundancy and anomalies through a process of decomposing relations that do not satisfy certain normal form conditions.

Uploaded by

mysadidvd009
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Database Design Theory: Functional Dependencies, Normal forms based on Primary Keys,

Second and Third Normal Forms, Boyce-Codd Normal Form, Multi valued Dependencies and
Fourth Normal Form, Join Dependencies and Fifth Normal Form and some examples related to
functional dependency and normal forms.

Functional Dependencies
 Formal tool for analysis of relational schemas that enables us to detect and describe
some of the problems in precise terms.
Definition of Functional Dependency

 A functional dependency is a constraint between two sets of attributes from the


database.
 Given a relation R, a set of attributes X in R is said to functionally determine another
attribute Y, also in R, (written X→Y) if and only if each X value is associated with at
most one Y value.
 X is the determinant set and Y is the dependent attribute. Thus, given a tuple and the
values of the attributes in X, one can determine the corresponding value of the Y
attribute.
 The abbreviation for functional dependency is FD or f.d. The set of attributes X is
called the left-hand side of the FD, and Y is called the right-hand side.
 A functional dependency is a property of the semantics or meaning of the attributes.
The database designers will use their understanding of the semantics of the attributes
of R to specify the functional dependencies that should hold on all relation states
(extensions) r of R.
Consider the relation schema EMP_PROJ;

From the semantics of the attributes and the relation, we know that the following functional
dependencies should hold:
a) Ssn → Ename
b) Pnumber →{Pname, Plocation}
c) {Ssn, Pnumber}→ Hours
 These functional dependencies specify that
a) The value of an employee’s Social Security number (Ssn) uniquely
determines the employee name (Ename)
b) The value of a projects number (Pnumber) uniquely determines the project
name (Pname) and location (Plocation) and
c) A combination of Ssn and Pnumber values uniquely determines the
number of hours the employee currently works on the project per week
(Hours).
 Alternatively,we say that Ename is functionally determined by (or functionally
dependent on) Ssn, or given a value of Ssn, we know the value of Ename, and so on.
 Relation extensions r(R) that satisfy the functional dependency constraints are called
legal relation states (or legal extensions) of R.
 A functional dependency is a property of the relation schema R, not of a particular
legal relation state r of R.
 Therefore, a Functional Dependencies cannot be inferred automatically from a given
relation extension r but must be defined explicitly by someone who knows the
semantics of the attributes of R.
EXAMPLE:

Diagrammatic notation for displaying Functional Dependencies


 Each Functional Dependencies is displayed as a horizontal line
 The left-hand-side attributes of the Functional Dependencies are connected by vertical
lines to the line representing the Functional Dependencies
 The right-hand-side attributes are connected by the lines with arrows pointing toward
the attributes.
 Each Functional Dependencies is displayed as a horizontal line
 The left-hand-side attributes of the FD are connected by vertical lines to the line
representing the FD
 The right-hand-side attributes are connected by the lines with arrows pointing toward
the attributes.

Fig: diagrammatic notation for displaying FDs

INFERENCE
RULES:

EXAMPLE: Given FD’s for Relation R{A,C,D,E,F}, Find Closure of FD set by applying
Amstrong’s Axims.
A->B, A->C, CD->E, CD->F, B->E.
Solution:
EXAMPLE: Compute the closure of the following set F of functional dependencies for
relational schema R = (A,B,C,D,E) A->BC, CD->E, B->D, E->A
EXAMPLE: Give Armstrong’s axioms and using it find the closure of the following FD
set.
A->B, AB->C, D->AC, D->E
Solution:

EXAMPLE: R={A,B,C,D,E,F} and FDs are A->BC, E->CF, B->E, CD->EF compute
closure of {A,B}+
Solution:

EXAMPLE: Consider schema EMPLOYEE(E-ID, E-NAME, E-CITY, E-STATE) and


FD = {E-ID->E-NAME, E-ID->E-CITY, E-ID->E-STATE, E-CITY->E-STATE}
1) Find attribute of closure for (E-ID)+
2) Find (E-NAME)
+
Solution:

KEYS AND FUNCTIONAL DEPENDENCIES:


PROPERTIES OF FUNCTIONAL DEPENDENCIES:
1) Reflexive: If Y⊆X then X → Y is a Reflexive Functional Dependency.
Ex: AB→A , A⊆AB holds. Therefore AB→A is a Reflexive Functional Dependency.
2) Augmentation: If X→Y is a functional dependency then by augmentation, XZ→YZ is
also a functional dependency.
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.
CLOSURE SET OF A FUNCTIONAL DEPENDENCY (F+)
It is a set of all functional dependencies that can be determined using the given set of
dependencies. It is denoted by F+.
Attribute Closure (X+): It is a set of all the attributes that can be determined using X. It is
denoted by X+, where X is any set of attributes.
Example:
R(A,B,C) F:{A→B , B→C}
A+={A,B,C} B+={B,C} C+={C}
AB+={A,B,C} AC+={A,C,B} BC+={B,C} ABC+={A,B,C}
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.
PROPERTIES OF RELATIONAL DECOMPOSITION:
LOSS-LESS JOIN:
EXAMPLE: Consider the following relation R(A, B, C, D) and FDs A->BC, is the
decomposition of R into R1(A, B, C), R2(A, D). Check if the decomposition is lossless
join or not.
Solution:

Normal forms based on Primary Keys


NORMAL FORMS:

We assume that a
 Set of functional dependencies is given for each relation Each relation has a
designated primary key.
 This information combined with the tests (conditions) for normal forms drives the
normalization process for relational schema design.
 First three normal forms for relation takes into account all candidate keys of a relation
rather than the primary key.
Normalization of Relations
 The normalization process, as first proposed by Codd (1972a), takes a relation schema
through a series of tests to certify whether it satisfies a certain normal form.
 Initially, Codd proposed three normal forms, which he called first, second, and third
normal form
 All these normal forms are based on a single analytical tool: the functional
dependencies among the attributes of a relation
 A fourth normal form (4NF) and a fifth normal form (5NF) were proposed, based on
the concepts of multivalued dependencies and join dependencies, respectively
Normalization of data can be considered a process of analyzing the given relation
schemas based on their FDs and primary keys to achieve the desirable properties of
1) minimizing redundancy and
2) minimizing the insertion, deletion, and update anomalies
 It can be considered as a “filtering” or “purification” process to make the design have
successively better quality.
 Unsatisfactory relation schemas that do not meet certain conditions the normal form
tests are decomposed into smaller relation schemas that meet the tests and hence
possess the desirable properties.
 Thus, the normalization procedure provides database designers with the following:
 A formal framework for analyzing relation schemas based on their keys
and on the functional dependencies among their attributes.
 A series of normal form tests that can be carried out on individual relation
schemas so that the relational database can be normalized to any desired
degree.
 Definition: The normal form of a relation refers to the highest normal form
condition that it meets, and hence indicates the degree to which it has been
normalized.

An attribute of relation schema R is called a prime attribute of R if it is a member of some


candidate key of R. An attribute is called nonprime if it is not a prime attribute that is, if it is
not a member of any candidate key.

In WORKS_ON relation Both Ssn and Pnumber are prime attributes whereas other attributes
are nonprime.
First Normal Form
 Defined to disallow multivalued attributes, composite attributes, and their
combinations.
 It states that the domain of an attribute must include only atomic (simple, indivisible)
values and that the value of any attribute in a tuple must be a single value from the
domain of that attribute 1NF disallows relations within relations or relations as
attribute values within tuples.
 The only attribute values permitted by 1NF are single atomic (or indivisible) values.
Consider the DEPARTMENT relation schema shown in Figure below

 Primary key is Dnumber


We assume that each department can have a number of locations
 The DEPARTMENT schema and a sample relation state are shown in Figure below

 As we can see, this is not in 1NF because Dlocations is not an atomic attribute, as
illustrated by the first tuple in Figure
There are three main techniques to achieve first normal form for such a relation:
1) Remove the attribute Dlocations that violates 1NF and place it in a separate relation
DEPT_LOCATIONS along with the primary key Dnumber of DEPARTMENT. The
primary key of this relation is the combination {Dnumber, Dlocation}. A distinct
tuple in DEPT_LOCATIONS exists for each location of a department. This
decomposes the non-1NF relation into two 1NF relations.
2) Expand the key so that there will be a separate tuple in the original DEPARTMENT
relation for each location of a DEPARTMENT. In this case, the primary key becomes
the combination {Dnumber, Dlocation}. This solution has the disadvantage of
introducing redundancy in the relation

3) If a maximum number of values is known for the attribute for example, if it is known
that at most three locations can exist for a department replace the Dlocations attribute
by three atomic attributes: Dlocation1, Dlocation2, and Dlocation3.
EXAMPLE:
Second Normal Form
Third Normal Forms
EXAMPLE:
What is normalization? Normalize below given relation upto 3NF STUDENT.
EXAMPLE:
Consider the relation R(ABC) with following FD A->B, B->C and C->A. What is the
normal form of R?olution:

You might also like