You are on page 1of 26

Normalization

Functional Dependencies
• A functional dependency is a constraint that specifies the relationship
between two sets of attributes where one set can accurately
determine the value of other sets. It is denoted as X → Y, where X is a
set of attributes that is capable of determining the value of Y. The
attribute set on the left side of the arrow, X is called Determinant,
while on the right side, Y is called the Dependent.
Data base anomalies
• Anomalies are problems that can occur in poorly planned, un-
normalised databases where all the data is stored in one table (a flat-
file database).
• Types:

• 1. Update
• 2. Insert
• 3 Delete anomalies
Types
• Insertion Anomaly - The nature of a database may be such that it is not
possible to add a required piece of data unless another piece of
unavailable data is also added. E.g. A library database that cannot store
the details of a new member until that member has taken out a book.

• Deletion Anomaly - A record of data can legitimately be deleted from a


database, and the deletion can result in the deletion of the only
instance of other, required data, E.g. Deleting a book loan from a library
member can remove all details of the particular book from the database
such as the author, book title etc.
• Modification Anomaly - Incorrect data may have to be changed, which
could involve many records having to be changed, leading to the
possibility of some changes being made incorrectly.
Empno Projno Ename Pname No_hours
E1 P11 A Adv 11
E2 P10 B Billing 12
E6 P10 C Billing 15
E3 P12 D Seals 20

E5 P10 E Billing 10

1.Update P10—Billing to accounting


2. We can not insert new project without assigning employees
3.Deletion P12 – losing detail of employee D
Functional dependency
• Full functional dependency
• Partial functional dependency
• Trivial functional dependency
• Non Trivial functional dependency
• Transitive functional dependency
• Multi-valued functional dependency
Functional dependency
•A B
• A-determinant
• B-determined

Part_name Cost
Hard disk 1500
Pen drive 700
Hard disk 1500
CD 10
Pen drive 700
Full functional dependency
• An attribute is FFD on a set of attributes if
• It is functionally dependent on S and
• Not functionally dependent on any proper subset of S.
Roll_n NAme Course_id course_title Grade
um

1 Raj CSE301 DBMS A

1 Raj CSE306 NW C

2 Ankur CSE301 DBMS B

2 Ankur CSE306 NW A

3 Arun CSE316 SOFT ENGG C

roll_num ,course_id Grade


Name and course_title are not fully functional dependent on composite key
Partial dependency
• The value of one attribute is dependent on another attribute of
relation which is a part of composite key.

• Name is partially dependent on roll number.


Decomposition of tables
• Lossy decomposition
• Lossless decomposition
Lossless Join and Dependency Preserving
Decomposition
• Decomposition of a relation is done when a relation in relational
model is not in appropriate. Relation R is decomposed into two or
more relations if decomposition is lossless join as well as dependency
preserving.
• Lossless Join Decomposition
• 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:

• 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)
• Intersection of Attributes of R1 and R2 must not be NULL.
Att(R1) ∩ Att(R2) ≠ Φ
• Common attribute must be a key for at least one relation (R1 or R2)
Att(R1) ∩ Att(R2) -> Att(R1) or Att(R1) ∩ Att(R2) -> Att(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 a lossless
join decomposition as:

• First condition holds true as Att(R1) U Att(R2) = (ABC) U (AD) = (ABCD) = Att(R).
• Second condition holds true as Att(R1) ∩ Att(R2) = (ABC) ∩ (AD) ≠ Φ
• Third condition holds true as Att(R1) ∩ Att(R2) = A is a key of R1(ABC) because A->BC is given.
Dependency Preserving Decomposition
• 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).
• GATE Question: Consider a schema R(A,B,C,D) and functional dependencies A->B and C->D. Then the decomposition of R
into R1(AB) and R2(CD) is [GATE-CS]
• A. dependency preserving and lossless join
• B. lossless join but not dependency preserving
• C. dependency preserving but not lossless join
• D. not dependency preserving and not lossless join

• Answer: For lossless join decomposition, these three conditions must hold true:

• Att(R1) U Att(R2) = ABCD = Att(R)


• Att(R1) ∩ Att(R2) = Φ, which violates the condition of lossless join decomposition. Hence the decomposition is not
lossless.
• For dependency preserving decomposition,
• A->B can be ensured in R1(AB) and C->D can be ensured in R2(CD). Hence it is dependency preserving decomposition.
• So, the correct option is C.
Consider following table

Model Price Make

N12 10000 CANON

P20 12000 NIKON

A73 15000 CANON

This can be further divided as following

Model Make price make


N12 CANON 10000 CANON
P20 NIKON 12000 NIKON
A73 CANON 15000 CANON
Now try to re-create original table

model price make

N12 10000 CANON

N12 15000 CANON

P20 12000 NIKON

A73 10000 CANON

A73 15000 CANON


Properties of Decomposition
• Following are the properties of Decomposition,
1. Lossless Decomposition
2. Dependency Preservation
3. Lack of Data Redundancy

You might also like