dbms 4nf & 5nf

12
SUBJECT – DBMS TOPIC – FOURTH NORMAL FORM(4NF) & FIFTH NORMAL FORM(5NF) 7/17/22 1

Upload: soham-kansodaria

Post on 12-Apr-2017

277 views

Category:

Engineering


7 download

TRANSCRIPT

Page 1: Dbms 4NF & 5NF

1

SUBJECT – DBMS

TOPIC – FOURTH NORMAL FORM(4NF) & FIFTH NORMAL FORM(5NF)

May 3, 2023

Page 2: Dbms 4NF & 5NF

2

LEVELS OF NORMALIZATION • Levels of normalization based on the

amount of redundancy in the database.• Various levels of normalization are:

1. First Normal Form (1NF)2. Second Normal Form (2NF)3. Third Normal Form (3NF)4. Boyce-Codd Normal Form (BCNF)5. Fourth Normal Form (4NF)6. Fifth Normal Form (5NF)

May 3, 2023

Redundancy

Num

ber

of T

able

s

Com

plex

ity

Most databases should be 3NF or BCNF in order to avoid the database anomalies.

Page 3: Dbms 4NF & 5NF

3

FOURTH NORMAL FORM(4NF)

May 3, 2023

• Fourth normal form eliminates independent many-to-one relationships between columns.

• To be in Fourth Normal Form, 1. a relation must first be in Boyce-Codd Normal

Form. 2. a given relation may not contain more than one

multi-valued attribute.

• The multi-valued dependency X→Y holds in a relation R if whenever we have two tuples of R that same in all the attributes of X, then we can swap their Y components and get two new tuples that are also in R.

Page 4: Dbms 4NF & 5NF

4May 3, 2023

Example 1

• Primary key→{Student_ID , Subject , Activity }

• Many Student_ID have same Subject.• Many Student_ID have same Activity.• Thus violates 4NF.

Student_ID Subject Activity100 Music Swimming100 Accounting Swimming100 Music Tennis100 Accounting Tennis150 Math Jogging

Page 5: Dbms 4NF & 5NF

5May 3, 2023

Student_ID Subject

100 Music100 Accounting150 Math

Student_ID Activity100 Swimming100 Tennis150 jogging

Example 1(convert to 4NF)Old Scheme→{Student_ID , Subject , Activity}New Scheme →{Student_ID , Subject}New Scheme →{Student_ID , Activity}

Example 1

Page 6: Dbms 4NF & 5NF

6May 3, 2023

Example 2

• Primary key→{Manager , Child , Employee }• Each manager can have more than one child.• Each manager can supervise more than one employee. • Thus violates 4NF.

Manager Child EmployeeJim Beth AliceMary Bob JaneMary NULL Adam

Page 7: Dbms 4NF & 5NF

7May 3, 2023

Manager Child

Jim BethMary Bob

Manager EmployeeJim AliceMary JaneMary Adam

Example 2(convert to 4NF)Old Scheme→{Manager , Child , Employee }New Scheme →{Manager , Child}New Scheme →{Manager , Employee}

Example 2

Page 8: Dbms 4NF & 5NF

8

FIFTH NORMAL FORM(5NF)

May 3, 2023

A table is in the 5NF if it’s in 4NF and if for all join dependency of (, , ,…….., ) in R ,every Ri is a super key for R.

A table is in the 5NF if it”s in 4NF and if it can’t have a loseless decomposition in to any number of smaller tables.

It’s also known as Project-join normal form(PJ/NF). Fifth normal form is satisfied when all tables are

broken into as many tables as possible in order to avoid redundancy. Once it is in fifth normal form it cannot be broken into smaller relations without changing the facts or the meaning. 

Page 9: Dbms 4NF & 5NF

9May 3, 2023

Example 1Agent Company ProductSuneet ABC NutRaj ABC BoltRaj ABC NutSuneet CDE BoltSuneet ABC bolt

• The table is in 4NF because it contains no multi-valued dependency.

• Suppose that table is decomposed into it’s three relations P1,P2 & P3.

Page 10: Dbms 4NF & 5NF

10May 3, 2023

Agent CompanySuneet ABCSuneet CDERaj ABC

P1Agent ProductSuneet NutSuneet BoltRaj BoltRaj Nut

P2

Company ProductABC NutABC BoltCDE Bolt

P3

Example 1

Page 11: Dbms 4NF & 5NF

11May 3, 2023

• From above tables or relations if we perform natural join between any of two above relations i.e P1P2 , P2P3 or P1P3 then extra rows are added so this decomposition is called lossy decomposition.

• But if we perform natural join between the above three relation then no extra rows are added so this decomposition is called loseless decomoposition.

• So, above three tables P1,P2 and P3 are in 5NF.

Page 12: Dbms 4NF & 5NF

12

THANK YOU

May 3, 2023