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

CIS340 - Lecture 15-41

Uploaded by

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

CIS340 - Lecture 15-41

Uploaded by

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

‫‪1‬‬

‫‪Functional Dependencies‬‬
‫‪and Normalization for‬‬
‫‪Relational Databases‬‬

‫تنبيه ‪ :‬شرائح العرض (‪ )Slides‬هي وسيلة لتوضيح الدرس واداة من‬


‫االدوات في ذلك‪.‬‬

‫حيث المرجع االساسي للمادة هي الكتاب المعتمد في وصف‬


‫المقرر‬
Second Normal Form 2NF
2

 A relation schema R is in second normal form (2NF) if


every non-prime attribute A in R is fully functionally
dependent on the primary key

 The above definitions consider the primary key only

 The following more general definitions take into


account relations with multiple candidate keys

 A relation schema R is in second normal form


(2NF) if every non-prime attribute A in R is fully
functionally dependent on every key of R

Chapter 10-2
Example
3

R1(ID, Name, Type Age,


1NF Owner)
R2(ID, Visit Date, PNO, PName)

R1(ID, Name, Type


Age, Owner)
2NF R2A(ID, VisitDate, PNO )
R2B(PNO,
PName )
R1(ID, Name, Type Age,
Owner)
R2A(ID, VisitDate,
3NF PNO )
R2B(PNO,
PName )
Third Normal Form 3NF
4

 A relation schema R is in third normal form (3NF)


if
 It is in 2NF and
 No non-prime attribute A in R is transitively dependent on
the primary key

 A relation schema R is in third normal form (3NF) if


whenever a FD X → A holds in R, then either:
(a) X is a superkey of R, or
(b) A is a prime attribute of R
 Superkey of relation schema R a set of attributes S of R that contains a key of R

Chapter 10-4
Example
5

2NF
Example
6

2NF

3NF
Example
7

PET ID PET NAME PET TYPE PET AGE OWNER VISIT DATE PROCEDURE
246 ROVER DOG 12 SAM COOK JAN 13/2002 01 - RABIES VACCINATION
MAR 27/2002 10 - EXAMINE and TREAT WOUND
APR 02/2002 05 - HEART WORM TEST

298 SPOT DOG 2 TERRY KIM JAN 21/2002 08 - TETANUS VACCINATION


MAR 10/2002 05 - HEART WORM TEST

341 MORRIS CAT 4 SAM COOK JAN 23/2001 01 - RABIES VACCINATION


JAN 13/2002 01 - RABIES VACCINATION

519 TWEEDY BIRD 2 TERRY KIM APR 30/2002 20 - ANNUAL CHECK UP


APR 30/2002 12 - EYE WASH
Example
8

 Un-Normalized Form

R(ID, Name, Type, Age, Owner, {Visit( VDate,


PNO, PNAME)})
R
V
ID Name Type Age Owner
VDate PNO PName
2NF Example
9

 Consider the relation schema LOTS which describes


parcels of land for sale in various country

 Suppose that there is two candidate keys PROPERTY_ID#


, {COUNTY_NAME, LOT#}, we choose PROPERTY_ID# as
a primary key, so FD1, FD2 are hold
2NF Example
10

 Suppose that the following two additional FDs


hold in LOTS
FD3: COUNTY_NAME → TAX_RATE
FD4: AREA → PRICE

 The FD3 violate 2NF because TAX_RATE is


partially dependent on the candidate key
{COUNTY_NAME, LOT# }
 The FD4 doe not violate the 2NF
2NF Example
11

 To Normalize LOTS into 2NF, we decompose it


into two relations LOTS1, LOTS2
 by removing the attribute TAX_RATE that violates
2NF and placing it into another relation LOTS2
3NF Example
12

 According to 3NF definition, LOTS2 is in


3NF

 However, FD4 in LOTS1 violates 3NF because


AREA is not a superkey and PRICE is not a
prime attribute in LOTS1
3NF Example
13

 To normalize LOTS1 into 3NF, we


decompose it into the relation schemas
LOTS1A and LOTS1B
 We construct LOTS1A by removing the
attribute price that violate 3NF
Is this table in 2NF
14
Is this table in 2NF
15

 Current Work Location, is dependent on


only part of the candidate key, namely
Employee. Therefore the table is not in
2NF
2NF

You might also like