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

Func Depend Normalization

The document discusses functional dependencies and normalization techniques in database design. It covers topics like full and partial functional dependencies, closure sets, candidate keys, first, second and third normal forms. Examples are provided to illustrate checking for valid dependencies and normalizing relations.

Uploaded by

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

Func Depend Normalization

The document discusses functional dependencies and normalization techniques in database design. It covers topics like full and partial functional dependencies, closure sets, candidate keys, first, second and third normal forms. Examples are provided to illustrate checking for valid dependencies and normalizing relations.

Uploaded by

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

Functional Dependency

DBMS

1
Functional Dependency
If there is a dependency from X to Y i.e. XY

• If we get different values of Y on the same value of X, then dependency is


invalid

• If we get same value of Y on the same vale of X, then dependency valid

• If all values of X are unique/different then dependency is valid

• If all values of Y are same then dependency is valid

2
If there is a dependency from A to B i.e. AB
A B A B A B A B
a 5 a 5 a 5 a 5
b 8 b 8 b 7 b 5
a 7 a 5 c 5 a 5
c 9 c 9 d 4 c 5
b 3 b 8 e 6 b 5
1. Invalid 2. Valid 3. Valid 4. Valid

3
Types of Functional Dependency
 Full Functional Dependency
• If all non-prime/non-key attributes are entirely dependent on the prime/key
attribute/candidate key, is called full functional dependency.

 Partial Dependency
• If some non-prime / non-key attributes are entirely dependent on the prime / key
attribute/candidate key & Some non-prime / non-key attributes are partially
dependent on the part of prime/key attribute/candidate key, is called partial
dependency.
 Transitive Dependency
• If any non-prime/non-key attribute is dependent on other non-prime/non-key
attribute, is called transitive dependency.

4
Functional Dependencies
Example: To check dependency for the following A B C D
dependencies with data given in the table
i) ABC a1 5 4 3
ii) CDAB
b1 a 4 5
iii) BCD
a1 5 4 2
In i) a1 searching two values 5,4 in Ist & IIIrd row, here we
get same value of BC for the same value of A, b1 finding a,4 c1 b 4 6
and c1 finding b,4
this means i) dependency is valid
In ii) the values of CD(4,3 & 4,5 & 4,2 & 4,6) are unique
this means ii) dependency is valid
In iii) on the same value of B (value-5), we are getting
different values of CD (i.e 4,3 & 4,2)
this means iii) dependency is invalid

5
Functional Dependencies
Example: To check dependency is valid or invalid for the A B C
following dependencies with data given in the table
i) AB && BCA 2 3 6
ii) BC && ABC 4 6 6
iii) AC && BCA
4 8 4
In i) AB is invalid
this means i) dependency is invalid 2 5 4
In ii) BC is valid, because all values of B are unique
ABC is valid, because all values of AB are unique
this means ii) dependency is valid
In iii) AC is invalid
this means iii) dependency is invalid

6
Closure Set of Attributes
R1(A,B.C,D,E) R2(A,B.C,D,E,F) R3(A,B,C,D,E,F)
ABC ABC CDE
BD BCAD DAF
DA DE ECF
EF
B+ (closure set of B)-? (AB) + (closure set of AB)-? (DE) + (closure set of DE)-?
B=B AB=AB DE=DE
B=BD AB=ABC DE=ADEF
B=ABD AB=ABCD DE=ACDEF (Final)
B=ABCD(final) AB=ABCDE (BC)=BCDEAF=ABCDEF
AB=ABCDEF (final)

7
Finding Candidate Key (CK)
R1(A,B,C,D) R2(A,B,C,D) R3(A,B.C,D,E)
AB ABCD CD
BD DA DAB
DA EC
Here C is not dependent on Here B is not dependent on any Here E is not dependent on any
any other key other key other key
(AC) + =ABC (AB) + =ABCD (E) + =CE
=ABCD (BC) + =BC - No =CDE
(BC) + =BDC (BD) + =BDA =ABCDE
=ABDC =ABCD (E) is a CK.
=ABCD (AB) ,(BD) are CK.
(CD) + =CDA=ABCD
(AC) ,(BC) & (CD) are CK.

8
Finding Candidate Key (CK)
R4(A,B.C,D,E) R5(A,B.C,D,E,F) R6(A,B.C,D,E,F)
ABC ABC CDE
BD BCAD DAF
DA DE ECF
EF
Here E is not dependent on Here B is not dependent on any Here B is not dependent on any
any other key other key other key
(AE) + =ABCE (AB) +=ABC=ABCD (AB) +=AB -No
=ABCDE =ABCDE=ABCDEF (BC) +=BCDE=BCDEF
(BE) + =BDE (BC) +=ABCD=ABCDE =ABCDEF
=ABDE=ABCDE =ABCDEF (BD) +=BDAF -No
(CE) + =CE -No (BD) +=BDE=BDEF -No (BE) +=BECF = BCDEF
+
(DE) =ADE (BE) +=BEF -No =ABCDEF
=ABCDE (BF) +=BF -No (BF) +=BF -No
(AE) ,(BE) , (DE) are CK. (AB) ,(BC) are CK. (BC) ,(BE) are CK.

9
Normalization
What is Normalization?
Normalization is a database design technique that reduces data redundancy and
eliminates undesirable characteristics like Insertion, Update and Deletion Anomalies.
Normalization rules divides larger tables into smaller tables and links them using
relationships. The purpose of Normalization in SQL is to eliminate redundant
(repetitive) data and ensure data is stored logically.

Types of Normal Forms

1. First Normal Form (1NF)


2. Second Normal Form (2NF)
3. Third Normal Form (3NF)

10
First Normal Form (1NF)
Any relation (table) will be in 1NF if it has no repeating groups of data. Each cell in a
relation contain only one value, value should be atomic. That could not be decomposed
further into smaller parts.

Roll No. Name Subject Course Roll No. Name Subject Course
1011 Vikas DBMS MCA 1011 Vikas DBMS MCA
WT MCA 1011 Vikas WT MCA
TOC MCA
1011 Vikas TOC MCA
1012 Hemant DBMS MCA
WT MCA 1012 Hemant DBMS MCA
TOC MCA 1012 Hemant WT MCA
This is not allowed, this is not in 1NF 1012 Hemant TOC MCA
This is in 1NF

11
Second Normal Form (2NF)
Any relation (table) will be in 2NF if every non-prime attribute depends on the entire /
candidate key, not just part of it.
No non-prime attributes is partially dependent on a part of candidate key or entire key.
R(A,B,C,D) R:
ABD R1(A,B,D)
BC R2(B,C)
Relation R is converted in two relations R1 &
R2.This is now in 2NF.
(AB) +=ABCD Here
(B)=C In R1 D is fully dependent on AB (entire key)
Here, AB is a candidate key In R2 C is fully dependent on B (entire key)
A,B – Prime attribute
C,D – Non-prime attribute
D is entirely dependent on AB but C is
partially dependent on B, B is the part of
key. This relation is not in 2NF.

12
Third Normal Form (3NF)
Any relation (table) will be in 3NF if it is in 2NF and no non-prime attribute is
functionally dependent on other non-prime attribute.
No transitive dependency should be there.
R(B.C,D) R:
BC R1(B,C)
CD R2(C,D)
Relation R is converted in two relations R1 &
R2.This is now in 3NF.
Here, Here
B, C, D – Non-prime attributes In R1 C is fully dependent on B.
D is dependent on C and C is dependent on B, In R2 D is fully dependent on C.
This is the case of transitive dependency. This
relation is not in 3NF.

13

You might also like