the database normalization

Discussion in 'Databases' started by runeveryday, Sep 3, 2009.

  1. #1
    
    StudyNo   |   Name   |   Sex   |     Email       |   ClassNo  | ClassAddress
    01                john        Male       kkkk@ee.net    200401      A building 1
    02                mary       famale    kkk@fff.net       200402      A building 2 
    
    
    HTML:
    StudyNo is the primary key,a friend of mine said the above is suit for the first normal form,but doesn't fit for the second.the reason is "ClassAddress" partial dependencies on the key ClassAddress,
    why?who can explain it to me!
    thanks very much.
     
    runeveryday, Sep 3, 2009 IP
  2. marshalprince

    marshalprince Peon

    Messages:
    435
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    StudyNo | Name | Sex | Email |
    01 john Male
    02 mary famale

    ClassNo | ClassAddress | StudyNo
    200401 A building 1 01
    200402 A building 2 02

    is in the second normal form
     
    marshalprince, Sep 3, 2009 IP
  3. runeveryday

    runeveryday Active Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    why the above is wrong? thank you!
     
    runeveryday, Sep 3, 2009 IP
  4. Jamie18

    Jamie18 Peon

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    since many rows in your table will have the same classno, they will also have the same classaddress.. therefore having both classno and classaddress provides redundant information.

    creating a second table to store classno's and classaddress's means you can look up classaddress's based on the classno
     
    Jamie18, Sep 4, 2009 IP
  5. nixande

    nixande Well-Known Member

    Messages:
    85
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    #5
    it's been a long time since i'v done proper normalisation, but as a hint in general

    you need more data in the base to see the to be normalized stuff in the beginning.
    every time you do have a repetition you need to take that 'out' in making as long new tables with lookups as you can. also you need to determine the connection between the two.
    you cannot have n:m relationships.

    starting with the example
    each student can have many classes, and every class can have many students - not allowed. there is a third one missing.

    this one stays, no repetition there:
    this one has doubles which you can see if you do add new entries
    you need to split them up as well:


    which makes your 'connecting one'

    this way, no where is any double information.
    students to "ClassNo | StudyNo" is 1:n - each student can have many classes, but each entry can only be one student.

    each entry can also be only one classroom - class room lookup to "ClassNo | StudyNo" is also 1:n; each classroom can have many entrys in "ClassNo | StudyNo" but each line in "ClassNo | StudyNo" goes back to only one class room
     
    nixande, Sep 5, 2009 IP