SlideShare ist ein Scribd-Unternehmen logo
1 von 27
5




    Database Design 1:
Some Normalization Examples




                          1
5
Dependencies: Definitions
x   Multivalued Attributes (or repeating groups): non-
    key 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    Name       Course_ID       Units
        101      Lennon      MSI 250         3.00
        101      Lennon      MSI 415         3.00
        125      Johnson     MSI 331         3.00


                                                           2
5
Dependencies: Definitions
x   Partial Dependency – when an non-key
    attribute is determined by a part, but not the
    whole, of a COMPOSITE primary key.
                               Partial
          CUSTOMER           Dependency



           Cust_ID   Name     Order_ID
            101      AT&T       1234
            101      AT&T        156
            125      Cisco      1250

                                                     3
5
Dependencies: Definitions

x   Transitive Dependency – when a non-
    key attribute determines another non-key
    attribute.          Transitive
                          Dependency

EMPLOYEE

    Emp_ID   F_Name   L_Name   Dept_ID   Dept_Name
     111      Mary     Jones      1         Acct
     122      Sarah   Smith       2        Mktg



                                                     4
5
Normal Forms: Review

x   Unnormalized – There are multivalued
    attributes or repeating groups
x   1 NF – No multivalued attributes or
    repeating groups.
x   2 NF – 1 NF plus no partial
    dependencies
x   3 NF – 2 NF plus no transitive
    dependencies
                                           5
5
Example 1: Determine NF
                            All attributes are directly
x   ISBN  Title            or indirectly determined
x   ISBN  Publisher           by the primary key;
                            therefore, the relation is
x   Publisher  Address           at least in 1 NF


    BOOK

     ISBN       Title     Publisher          Address




                                                          6
5
Example 1: Determine NF
                          The relation is at least in 1NF.
x   ISBN  Title             There is no COMPOSITE
x   ISBN  Publisher       primary key, therefore there
                          can’t be partial dependencies.
x   Publisher  Address     Therefore, the relation is at
                                   least in 2NF
    BOOK

     ISBN       Title     Publisher             Address




                                                             7
5
Example 1: Determine NF
                          Publisher is a non-key attribute,
x   ISBN  Title            and it determines Address,
x   ISBN  Publisher         another non-key attribute.
                           Therefore, there is a transitive
x   Publisher  Address   dependency, which means that
                            the relation is NOT in 3 NF.
    BOOK

     ISBN       Title     Publisher          Address




                                                              8
5
Example 1: Determine NF
                          We know that the relation is at
x   ISBN  Title          least in 2NF, and it is not in 3
x   ISBN  Publisher       NF. Therefore, we conclude
                            that the relation is in 2NF.
x   Publisher  Address

    BOOK

     ISBN       Title      Publisher            Address




                                                             9
5
    Example 1: Determine NF
x   ISBN  Title              In your solution you will write the
                                      following justification:
x   ISBN  Publisher         •    No M/V attributes, therefore at
x   Publisher                                least 1NF
                                •   No partial dependencies,
    Address                            therefore at least 2NF
                           •     There is a transitive dependency
                                (Publisher  Address), therefore,
                                               not 3NF
                             Conclusion: The relation is in 2NF

      BOOK

        ISBN       Title       Publisher            Address

                                                                    10
5
Example 2: Determine NF

x   Product_ID  Description
                       All attributes are directly or
                      indirectly determined by the
                   primary key; therefore, the relation
                             is at least in 1 NF
    ORDER

    Order_No   Product_ID         Description




                                                          11
5
Example 2: Determine NF

x   Product_ID  Description
                      The relation is at least in 1NF.
                 There is a COMPOSITE Primary Key (PK)
             (Order_No, Product_ID), therefore there can be
            partial dependencies. Product_ID, which is a part
             of PK, determines Description; hence, there is a
            partial dependency. Therefore, the relation is not
                   2NF. No sense to check for transitive
                              dependencies!

    ORDER

    Order_No       Product_ID           Description

                                                                 12
5
Example 2: Determine NF

x   Product_ID  Description
                   We know that the relation is at least
                      in 1NF, and it is not in 2 NF.
                    Therefore, we conclude that the
                           relation is in 1 NF.

    ORDER

    Order_No   Product_ID        Description




                                                           13
5
    Example 2: Determine NF
x   Product_ID 
    Description       In your solution you will write the
                              following justification:
                   1) No M/V attributes, therefore at least
                                        1NF
                       2) There is a partial dependency
                     (Product_ID  Description), therefore
                                     not in 2NF
                     Conclusion: The relation is in 1NF
      ORDER

       Order_No    Product_ID           Description

                                                              14
5
Example 3: Determine NF
x   Part_ID  Description       Comp_ID and No are not
x   Part_ID  Price            determined by the primary
                               key; therefore, the relation
x   Part_ID, Comp_ID  No      is NOT in 1 NF. No sense
                                  in looking at partial or
                                transitive dependencies.


    PART

    Part_ID   Descr    Price    Comp_ID            No




                                                              15
5
Example 3: Determine NF
                            In your solution you will write
x   Part_ID  Description       the following justification:
                             2) There are M/V attributes;
x   Part_ID  Price
                                    therefore, not 1NF
x   Part_ID, Comp_ID  No   Conclusion: The relation is not
                                        normalized.


PART

Part_ID     Descr     Price      Comp_ID            No




                                                               16
5
Bringing a Relation to 1NF


STUDENT

 Stud_ID   Name      Course_ID   Units
  101      Lennon     MSI 250    3.00
  101      Lennon     MSI 415    3.00
  125      Johnson    MSI 331    3.00




                                         17
5
    Bringing a Relation to 1NF
x    Option 1: Make a determinant of the
    repeating group (or the multivalued
    attribute) a part of the primary key.
                    Composite
                    Primary Key

    STUDENT

     Stud_ID   Name      Course_ID   Units
      101      Lennon     MSI 250    3.00
      101      Lennon     MSI 415    3.00
      125      Johnson    MSI 331    3.00

                                             18
5
 Bringing a Relation to 1NF
x Option 2: Remove the entire repeating group from
  the relation. Create another relation which would
  contain all the attributes of the repeating group, plus
  the primary key from the first relation. In this new
  relation, the primary key from the original relation
  and the determinant of the repeating group will
  comprise a primary key.
  STUDENT

  Stud_ID     Name      Course_ID        Units
    101      Lennon      MSI 250         3.00
    101      Lennon      MSI 415         3.00
    125      Johnson     MSI 331         3.00

                                                            19
5
Bringing a Relation to 1NF
          STUDENT

          Stud_ID      Name
            101     Lennon
            125        Jonson


  STUDENT_COURSE

  Stud_ID     Course            Units
    101      MSI 250             3
    101      MSI 415             3
    125      MSI 331             3


                                        20
5
Bringing a Relation to 2NF

                  Composite
                  Primary Key


STUDENT

 Stud_ID   Name       Course_ID   Units
  101      Lennon       MSI 250   3.00
  101      Lennon       MSI 415   3.00
  125      Johnson      MSI 331   3.00


                                          21
5
Bringing a Relation to 2NF
x   Goal: Remove Partial Dependencies
                                   Partial
     Composite                  Dependencies
     Primary Key


    STUDENT

    Stud_ID        Name   Course_ID      Units
      101      Lennon      MSI 250       3.00
      101      Lennon      MSI 415       3.00
      125      Johnson     MSI 331       3.00


                                                 22
5
    Bringing a Relation to 2NF
x   Remove attributes that are dependent from the part
    but not the whole of the primary key from the original
    relation. For each partial dependency, create a new
    relation, with the corresponding part of the primary
    key from the original as the primary key.
    STUDENT

     Stud_ID    Name      Course_ID       Units
       101      Lennon     MSI 250         3.00
       101      Lennon     MSI 415         3.00
       125     Johnson     MSI 331         3.00


                                                             23
5
   Bringing a Relation to 2NF
CUSTOMER
                                             STUDENT_COURSE
Stud_ID     Name     Course_ID     Units
  101      Lennon     MSI 250      3.00
  101      Lennon     MSI 415      3.00
  125      Johnson    MSI 331      3.00       Stud_ID   Course_ID
                                               101       MSI 250
                                               101       MSI 415
                                               125       MSI 331

                                           COURSE
          Stud_ID                Name
            101                  Lennon
                                           Course_ID       Units
            125                 Johnson
                                            MSI 250        3.00
                                            MSI 415        3.00
                                            MSI 331        3.00
                                                                    24
5
Bringing a Relation to 3NF

x   Goal: Get rid of transitive dependencies.

                        Transitive
                       Dependency
EMPLOYEE

    Emp_ID   F_Name   L_Name    Dept_ID Dept_Name
     111      Mary     Jones         1     Acct
     122      Sarah   Smith          2    Mktg



                                                    25
5
Bringing a Relation to 3NF
x   Remove the attributes, which are dependent on a
    non-key attribute, from the original relation. For each
    transitive dependency, create a new relation with the
    non-key attribute which is a determinant in the
    transitive dependency as a primary key, and the
    dependent non-key attribute as a dependent.

EMPLOYEE

    Emp_ID     F_Name      L_Name    Dept_ID Dept_Name
     111        Mary        Jones       1          Acct
     122        Sarah       Smith       2         Mktg


                                                              26
5
    Bringing a Relation to 3NF
EMPLOYEE

 Emp_ID    F_Name    L_Name    Dept_ID Dept_Name
   111      Mary      Jones      1        Acct
   122      Sarah    Smith       2       Mktg


                    EMPLOYEE

                      Emp_ID                     F_Name       L_Name    Dept_ID
                              111                    Mary       Jones     1
                              122                    Sarah     Smith      2

                                      DEPARTMENT

                                        Dept_ID Dept_Name
                                                 1           Acct
                                                 2           Mktg

                                                                                  27

Weitere ähnliche Inhalte

Was ist angesagt?

Normalization in a Database
Normalization in a DatabaseNormalization in a Database
Normalization in a DatabaseBishrul Haq
 
Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)Oum Saokosal
 
The Database Environment Chapter 4
The Database Environment Chapter 4The Database Environment Chapter 4
The Database Environment Chapter 4Jeanie Arnoco
 
Normalization
NormalizationNormalization
Normalizationmomo2187
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalizationdaxesh chauhan
 
Normalization
NormalizationNormalization
Normalizationlingesan
 
Functional dependencies in Database Management System
Functional dependencies in Database Management SystemFunctional dependencies in Database Management System
Functional dependencies in Database Management SystemKevin Jadiya
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFOum Saokosal
 
DBMS architecture &; system structure
DBMS architecture &; system  structureDBMS architecture &; system  structure
DBMS architecture &; system structureRUpaliLohar
 
Ism normalization pine valley 2012
Ism normalization pine valley 2012Ism normalization pine valley 2012
Ism normalization pine valley 2012Akshit R Shah
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFBiplap Bhattarai
 

Was ist angesagt? (20)

Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Normalization in a Database
Normalization in a DatabaseNormalization in a Database
Normalization in a Database
 
NORMALIZACIÓN
NORMALIZACIÓN  NORMALIZACIÓN
NORMALIZACIÓN
 
Schema
SchemaSchema
Schema
 
Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)
 
The Database Environment Chapter 4
The Database Environment Chapter 4The Database Environment Chapter 4
The Database Environment Chapter 4
 
Normalization
NormalizationNormalization
Normalization
 
Normalization
NormalizationNormalization
Normalization
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalization
 
Normalization
NormalizationNormalization
Normalization
 
DBMS Unit 2 ppt.ppt
DBMS Unit 2 ppt.pptDBMS Unit 2 ppt.ppt
DBMS Unit 2 ppt.ppt
 
Functional dependencies in Database Management System
Functional dependencies in Database Management SystemFunctional dependencies in Database Management System
Functional dependencies in Database Management System
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Normalization
NormalizationNormalization
Normalization
 
DBMS architecture &; system structure
DBMS architecture &; system  structureDBMS architecture &; system  structure
DBMS architecture &; system structure
 
Chapter2
Chapter2Chapter2
Chapter2
 
Ism normalization pine valley 2012
Ism normalization pine valley 2012Ism normalization pine valley 2012
Ism normalization pine valley 2012
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
 

Kürzlich hochgeladen

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Normalization

  • 1. 5 Database Design 1: Some Normalization Examples 1
  • 2. 5 Dependencies: Definitions x Multivalued Attributes (or repeating groups): non- key 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 Name Course_ID Units 101 Lennon MSI 250 3.00 101 Lennon MSI 415 3.00 125 Johnson MSI 331 3.00 2
  • 3. 5 Dependencies: Definitions x Partial Dependency – when an non-key attribute is determined by a part, but not the whole, of a COMPOSITE primary key. Partial CUSTOMER Dependency Cust_ID Name Order_ID 101 AT&T 1234 101 AT&T 156 125 Cisco 1250 3
  • 4. 5 Dependencies: Definitions x Transitive Dependency – when a non- key attribute determines another non-key attribute. Transitive Dependency EMPLOYEE Emp_ID F_Name L_Name Dept_ID Dept_Name 111 Mary Jones 1 Acct 122 Sarah Smith 2 Mktg 4
  • 5. 5 Normal Forms: Review x Unnormalized – There are multivalued attributes or repeating groups x 1 NF – No multivalued attributes or repeating groups. x 2 NF – 1 NF plus no partial dependencies x 3 NF – 2 NF plus no transitive dependencies 5
  • 6. 5 Example 1: Determine NF All attributes are directly x ISBN  Title or indirectly determined x ISBN  Publisher by the primary key; therefore, the relation is x Publisher  Address at least in 1 NF BOOK ISBN Title Publisher Address 6
  • 7. 5 Example 1: Determine NF The relation is at least in 1NF. x ISBN  Title There is no COMPOSITE x ISBN  Publisher primary key, therefore there can’t be partial dependencies. x Publisher  Address Therefore, the relation is at least in 2NF BOOK ISBN Title Publisher Address 7
  • 8. 5 Example 1: Determine NF Publisher is a non-key attribute, x ISBN  Title and it determines Address, x ISBN  Publisher another non-key attribute. Therefore, there is a transitive x Publisher  Address dependency, which means that the relation is NOT in 3 NF. BOOK ISBN Title Publisher Address 8
  • 9. 5 Example 1: Determine NF We know that the relation is at x ISBN  Title least in 2NF, and it is not in 3 x ISBN  Publisher NF. Therefore, we conclude that the relation is in 2NF. x Publisher  Address BOOK ISBN Title Publisher Address 9
  • 10. 5 Example 1: Determine NF x ISBN  Title In your solution you will write the following justification: x ISBN  Publisher • No M/V attributes, therefore at x Publisher  least 1NF • No partial dependencies, Address therefore at least 2NF • There is a transitive dependency (Publisher  Address), therefore, not 3NF Conclusion: The relation is in 2NF BOOK ISBN Title Publisher Address 10
  • 11. 5 Example 2: Determine NF x Product_ID  Description All attributes are directly or indirectly determined by the primary key; therefore, the relation is at least in 1 NF ORDER Order_No Product_ID Description 11
  • 12. 5 Example 2: Determine NF x Product_ID  Description The relation is at least in 1NF. There is a COMPOSITE Primary Key (PK) (Order_No, Product_ID), therefore there can be partial dependencies. Product_ID, which is a part of PK, determines Description; hence, there is a partial dependency. Therefore, the relation is not 2NF. No sense to check for transitive dependencies! ORDER Order_No Product_ID Description 12
  • 13. 5 Example 2: Determine NF x Product_ID  Description We know that the relation is at least in 1NF, and it is not in 2 NF. Therefore, we conclude that the relation is in 1 NF. ORDER Order_No Product_ID Description 13
  • 14. 5 Example 2: Determine NF x Product_ID  Description In your solution you will write the following justification: 1) No M/V attributes, therefore at least 1NF 2) There is a partial dependency (Product_ID  Description), therefore not in 2NF Conclusion: The relation is in 1NF ORDER Order_No Product_ID Description 14
  • 15. 5 Example 3: Determine NF x Part_ID  Description Comp_ID and No are not x Part_ID  Price determined by the primary key; therefore, the relation x Part_ID, Comp_ID  No is NOT in 1 NF. No sense in looking at partial or transitive dependencies. PART Part_ID Descr Price Comp_ID No 15
  • 16. 5 Example 3: Determine NF In your solution you will write x Part_ID  Description the following justification: 2) There are M/V attributes; x Part_ID  Price therefore, not 1NF x Part_ID, Comp_ID  No Conclusion: The relation is not normalized. PART Part_ID Descr Price Comp_ID No 16
  • 17. 5 Bringing a Relation to 1NF STUDENT Stud_ID Name Course_ID Units 101 Lennon MSI 250 3.00 101 Lennon MSI 415 3.00 125 Johnson MSI 331 3.00 17
  • 18. 5 Bringing a Relation to 1NF x Option 1: Make a determinant of the repeating group (or the multivalued attribute) a part of the primary key. Composite Primary Key STUDENT Stud_ID Name Course_ID Units 101 Lennon MSI 250 3.00 101 Lennon MSI 415 3.00 125 Johnson MSI 331 3.00 18
  • 19. 5 Bringing a Relation to 1NF x Option 2: Remove the entire repeating group from the relation. Create another relation which would contain all the attributes of the repeating group, plus the primary key from the first relation. In this new relation, the primary key from the original relation and the determinant of the repeating group will comprise a primary key. STUDENT Stud_ID Name Course_ID Units 101 Lennon MSI 250 3.00 101 Lennon MSI 415 3.00 125 Johnson MSI 331 3.00 19
  • 20. 5 Bringing a Relation to 1NF STUDENT Stud_ID Name 101 Lennon 125 Jonson STUDENT_COURSE Stud_ID Course Units 101 MSI 250 3 101 MSI 415 3 125 MSI 331 3 20
  • 21. 5 Bringing a Relation to 2NF Composite Primary Key STUDENT Stud_ID Name Course_ID Units 101 Lennon MSI 250 3.00 101 Lennon MSI 415 3.00 125 Johnson MSI 331 3.00 21
  • 22. 5 Bringing a Relation to 2NF x Goal: Remove Partial Dependencies Partial Composite Dependencies Primary Key STUDENT Stud_ID Name Course_ID Units 101 Lennon MSI 250 3.00 101 Lennon MSI 415 3.00 125 Johnson MSI 331 3.00 22
  • 23. 5 Bringing a Relation to 2NF x Remove attributes that are dependent from the part but not the whole of the primary key from the original relation. For each partial dependency, create a new relation, with the corresponding part of the primary key from the original as the primary key. STUDENT Stud_ID Name Course_ID Units 101 Lennon MSI 250 3.00 101 Lennon MSI 415 3.00 125 Johnson MSI 331 3.00 23
  • 24. 5 Bringing a Relation to 2NF CUSTOMER STUDENT_COURSE Stud_ID Name Course_ID Units 101 Lennon MSI 250 3.00 101 Lennon MSI 415 3.00 125 Johnson MSI 331 3.00 Stud_ID Course_ID 101 MSI 250 101 MSI 415 125 MSI 331 COURSE Stud_ID Name 101 Lennon Course_ID Units 125 Johnson MSI 250 3.00 MSI 415 3.00 MSI 331 3.00 24
  • 25. 5 Bringing a Relation to 3NF x Goal: Get rid of transitive dependencies. Transitive Dependency EMPLOYEE Emp_ID F_Name L_Name Dept_ID Dept_Name 111 Mary Jones 1 Acct 122 Sarah Smith 2 Mktg 25
  • 26. 5 Bringing a Relation to 3NF x Remove the attributes, which are dependent on a non-key attribute, from the original relation. For each transitive dependency, create a new relation with the non-key attribute which is a determinant in the transitive dependency as a primary key, and the dependent non-key attribute as a dependent. EMPLOYEE Emp_ID F_Name L_Name Dept_ID Dept_Name 111 Mary Jones 1 Acct 122 Sarah Smith 2 Mktg 26
  • 27. 5 Bringing a Relation to 3NF EMPLOYEE Emp_ID F_Name L_Name Dept_ID Dept_Name 111 Mary Jones 1 Acct 122 Sarah Smith 2 Mktg EMPLOYEE Emp_ID F_Name L_Name Dept_ID 111 Mary Jones 1 122 Sarah Smith 2 DEPARTMENT Dept_ID Dept_Name 1 Acct 2 Mktg 27