Docsity

Purpose of Normalization - Data Base Management System - Lecture Slides, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Purpose of Normalization - Data Base Management System - Lecture Slides and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Purpose of Normalization

• To reduce the chances for anomalies to

occur in a database.

• normalization prevents the possible

corruption of databases stemming from

what are called "insertion anomalies,"

"deletion anomalies," and "update

anomalies."

Normal Forms

  • Each normal form is a set of conditions on a schema that guarantees certain properties (relating to redundancy and update anomalies)
  • First normal form (1NF) is the same as the definition of relational model (relations = sets of tuples; each tuple = sequence of atomic values)
  • Second normal form (2NF) – a research lab accident; has no practical or theoretical value – won’t discuss
  • The two commonly used normal forms are third normal form (3NF) and Boyce-Codd normal form (BCNF)

BCNF

  • Definition : A relation schema R is in BCNF if for

every FD X → Y associated with R either

  • Y ⊆ X (i.e., the FD is trivial) or
  • X is a superkey of R
  • Example : Person1( SSN, Name, Address )
  • The only FD is SSN → Name, Address
  • Since SSN is a key, Person1 is in BCNF

(non) BCNF Examples

  • Person ( SSN, Name, Address, Hobby )
    • The FD SSN → Name, Address does not satisfy requirements of BCNF - since the key is ( SSN, Hobby )
  • HasAccount ( AcctNum, ClientId, OfficeId )
    • The FD AcctNum → OfficeId does not satisfy BCNF requirements - since keys are ( ClientId, OfficeId ) and ( AcctNum, ClientId ); not AcctNum.

3NF Example

  • HasAccount ( AcctNum, ClientId, OfficeId )
    • ClientId , OfficeId → AcctNum
      • OK since LHS contains a key
    • AcctNum → OfficeId
      • OK since RHS is part of a key
  • HasAccount is in 3NF but it might still contain

redundant information due to AcctNumOfficeId (which is not allowed by BCNF)

Example (con’t)

A1 A2 A3 A4 A

R1 a(1) a(2) a(3) b(1,4) a(5)

R2 a(1) b(2,2) a(3) a(4) b(2,5)

R3 b(3,1) b(3,2) b(3,3) a(4) a(5)

Example (con’t)

By FD1: A1  A3 A

A1 A2 A3 A4 A

R1 a(1) a(2) a(3) b(1,4) a(5)

R2 a(1) b(2,2) a(3) a(4) b(2,5)

R3 b(3,1) b(3,2) b(3,3) a(4) a(5)

Example (con’t)

By FD2: A5  A1 A

A1 A2 A3 A4 A

R1 a(1) a(2) a(3) b(1,4) a(5)

R2 a(1) b(2,2) a(3) a(4) a(5)

R3 b(3,1) b(3,2) b(3,3) a(4) a(5)

Example (con’t)

FD2: A5  A1 A

we have a new result table

A1 A2 A3 A4 A

R1 a(1) a(2) a(3) a(4) a(5)

R2 a(1) b(2,2) a(3) a(4) a(5)

R3 a(1) b(3,2) b(3,3) a(4) a(5)

R(A,B,C,D,E)

A B C D E

R1(A,D) a1 b12 b13 a4 b

R2(A,B) a1 a2 b23 b24 b

R3(B,E) b31 a2 b33 b34 a

R4(C,D,E) b41 b42 a3 a4 a

R5(A,E) a1 b52 b53 b54 a

FD1: A->C

A B C D E

R1(A,D) a1 b12 b13 a4 b

R2(A,B) a1 a2 b13 b24 b

R3(B,E) b31 a2 b33 b34 a

R4(C,D,E) b41 b42 a3 a4 a

R5(A,E) a1 b52 b13 b54 a

FD3: C->D

A B C D E

R1(A,D) a1 b12 b13 a4 b

R2(A,B) a1 a2 b13 a4 b

R3(B,E) b31 a2 b13 a4 a

R4(C,D,E) b41 b42 a3 a4 a

R5(A,E) a1 b52 b13 a4 a

FD4: D,E->C

A B C D E

R1(A,D) a1 b12 b13 a4 b

R2(A,B) a1 a2 b13 a4 b

R3(B,E) b31 a2 a3 a4 a

R4(C,D,E) b41 b42 a3 a4 a

R5(A,E) a1 b52 a3 a4 a