5

Chapter 5
Database Design 1: Some Normalization Examples Spring 2006

1

5

Dependencies: Definitions 

Multivalued Attributes (or repeating groups): nonkey attributes or groups of non-key attributes the values of which are not uniquely identified by (directly or indirectly) (not functionally dependent on) the value of the Primary Key (or its part).
STUDENT Stud_ID 101 101 125 Name Lennon Lennon Johnson Course_ID MSI 250 MSI 415 MSI 331 Units 3.00 3.00 3.00 2

of a COMPOSITE primary key. CUSTOMER Cu I AT&T AT&T Ci P i l p nd ncy Od 1234 1 6 12 0 I 101 101 12 3 .5 Dependencies: Definitions  Partial Dependency ± when an non-key attribute is determined by a part. but not the whole.

Transitive Dependency EMPLOYEE Emp_ID 111 122 F_Name Mary Sarah L_Name Jones Smith Dept_ID 1 2 Dept_Name Acct Mktg 4 .5 Dependencies: Definitions  Transitive Dependency ± when a nonkey attribute determines another non-key attribute.

NF ± NF plus no partial dependencies NF ± NF plus no transitive dependencies 5 .5 Normal Forms: eview     Unnormalized ± There are multivalued attributes or repeating groups NF ± No multivalued attributes or repeating groups.

5 Example 1: Determine NF    ISBN Title ISBN Publisher Publisher ddress All a b a c ly o n c ly mn by h p ma y k y. h la on a l a n 1 NF BOOK ISBN T l P bl h A 6 . h fo .

Th no COMPOSITE p ma y k y.5 Example 1: Determine NF    ISBN Title ISBN Publisher Publisher ddress Th la on a l a n 1NF. Th fo . h fo h can¶ b pa al p n nc . h la on a l a n 2NF BOOK ISBN T l P bl h A 7 .

mn A . h a an v p n ncy. BOOK ISBN T l P bl h A 8 . wh ch m an ha h la on NOT n 3 NF. an ano h non-k y a b . Th fo .5 Example 1: Determine NF    ISBN Title ISBN Publisher Publisher ddress P bl h a non-k y a b .

5 Example 1: Determine NF    ISBN Title ISBN Publisher Publisher ddress W know ha h la on a l a n 2NF. an no n 3 NF. w concl ha h la on n 2NF. Th fo . BOOK ISBN T l P bl h A 9 .

(Publ h no 3NF la on n 2NF Conclu on: Th In you BOOK ISBN T l P bl h A 10 . h fo a l a 2NF a an v p n ncy 3) Th A ). h fo .5 Example 1: Determine NF    ISBN Title ISBN Publisher Publisher ddress olu on you w ll w h follow ng ju f ca on: 1) No M/V a bu . h fo a l a 1NF 2) No pa al p n nc .

therefore.5 xample 2: Determine NF  Product_ID Description All attributes are directly or indirectly determined by the primary key. the relation is at least in 1 NF ORD R Order_No roduct_ID Description 11 .

r t_ID. There i a COM OSITE rimary Key ( K) (Or er_N . there i a partial epen en y. theref re there an be partial epen en ie . etermine De ripti n. Theref re. N en e t he k f r tran itive epen en ie ! O DE Or er_N r t_ID De ripti n 12 .5 Example 2: Determine NF  Product_ID Description The relati n i at lea t in 1NF. r t_ID). whi h i a part f K. hen e. the relati n i n t 2NF.

Therefore.5 Example 2: Determine NF  Product_ID Description We know that the relation is at least in 1NF. ORDER Order_No roduct_ID Description 13 . we conclude that the relation is in 1 NF. and it is not in 2 NF.

theref re ( r n t in 2NF C n l i n: The relati n i in 1NF In y r O DE Or er_N r t_ID De ripti n 14 .5 Example 2: Determine NF  Product_ID Description l ti n y will write the f ll wing j tifi ati n: 1) N M/V attrib te . theref re at lea t 1NF 2) There i a partial epen en y t_ID De ripti n).

therefore. No sense in looking at partial or transitive dependencies.5 Exam le 3: etermine F    Part_ID Description Part_ID Price Part_ID. PART Part_I escr Price Com _I o 15 . omp_ID No Comp ID and No are not determined by the primary key. the relation is NOT in 1 NF.

5 Example 3: Determine NF    Part_ID Description Part_ID Price Part_ID. therefore. omp_ID No In yo r ol tion yo will write the following j tification: 1) There are M/V attrib tes. not 1 F Concl ion: The relation i not normalized. PART Part_I escr Price Com _I o 16 .

00 17 .00 3.5 Bringing a elation to 1NF STUDENT St 101 101 125 D Na e Lennon Lennon John on o rse D MSI 50 MSI 15 MSI 331 Units 3.00 3.

00 3.5 Bringing a elation to 1NF  Option 1: ake a determinant of the repeating group (or the multivalued attribute) a part of the primary key.00 3. Composite Primary Key STUDENT St 101 101 125 D Na e Lennon Lennon John on o rse D MSI 250 MSI 15 MSI 331 Units 3.00 18 .

. reate another relation which would contain all the attributes of the repeating group. the primary key from the original relation and the determinant of the repeating group will comprise a primary key. STUDENT Stud_ID Name Lennon Lennon 2 ohnson Course_ID I2 I I Units . . 19 .5 Bringing a elation to 1NF  Option 2: Remove the entire repeating group from the relation. plus the primary key from the first relation. In this new relation.

5 Bringing a elation to 1NF N t 101 125 N t 101 101 125 o r e MSI 250 MSI 415 MSI 331 n it 3 3 3 Na e Lennon Jonson 20 .

00 3.00 MSI 15 MSI 331 21 .5 Bringing a elation to 2NF o posite Pri ary Key T t NT _D 101 101 125 Na e Lennon Lennon Johnson o rse_ D MSI 0 Units 3.00 3.

00 22 .5 Bringing a elation to 2NF  Goal: Remove Partial Dependencies Partial Dependencies o posite Pri ary Key TUDENT t _D 101 101 125 Na e Lennon Lennon Johnson o rse_ D MSI 250 MSI 15 MSI 331 Units 3.00 3.00 3.

with the corresponding part of the primary key from the original as the primary key. create a new relation.5 Bringing a elation to 2NF  Remove attributes that are dependent from the part but not the whole of the primary key from the original relation. For each partial dependency.00 23 . TUDENT t _D 101 101 125 Na e Lennon Lennon Johnson o rse_ D MSI 250 MSI 15 MSI 331 Units 3.00 3.00 3.

00 3.00 5 t 101 101 125 o r e M S I 250 M S I 415 M S I 331 N t 101 101 125 Na e o r e M S I 250 M S I 415 M S I 331 nit 3.00 24 Lennon Lennon Johns on .Bringing a elation to 2NF N t 101 101 125 Na e Lennon Lennon Johnson o re MSI 250 MSI 415 MSI 331 nit 3.00 3.00 3.00 3.

Bringing a elation to 3NF  Goal: 5 Get rid of transitive dependencies. Transitive Dependency EMPLOYEE Emp_ID F_Name ar ara L_Name Jones it Dept_ID Dept_Name cct t 25 .

For each transitive dependency. EMPLOYEE Emp_ID F_Name ary arah L_Name Jones mith Dept_ID Dept_Name cct ktg 26 . from the original relation. create a new relation with the non-key attribute which is a determinant in the transitive dependency as a primary key. which are dependent on a non-key attribute.Bringing a elation to 3NF  5 Remove the attributes. and the dependent non-key attribute as a dependent.

Bringing a elation to 3NF LOY D 111 122 F Na e Mar Sarah L Na e Jones Smith De t D De t Na e 1 2 Acct Mktg 5 LOY D 111 122 F Na e Mar Sarah Smith L Na e De t D 1 2 D ART NT De t D De t Na e 1 2 Acct Mktg 27 .

Sign up to vote on this title
UsefulNot useful