Normalisation example.pdf

Embed Size (px)

Citation preview

  • 8/12/2019 Normalisation example.pdf

    1/3

    Normalisation Example

    EXAMPLE::1

    Student Example

    The following table depicts the set of attribute found in a University database:

    Student-No Student-Name Course-Code Course-Length (yrs) Unit-Code Unit-Name Lecturer001 Smith A 0! ! U"#

    U$% &atabases ''rogramming

    rown*reen

    00! Soap A10" " U$+U"#U #

    Algorithms &atabases '' usiness '

    urplerown,ed

    00% -ho A 0! ! U1U"+

    usiness '' &atabases '

    in. /range

    010 emon A! ! U1U$+

    usiness '' Algorithms

    in. urple

    Notes : A student attends one course and can ta.e any units during the course A unit may be presented as part of any course and is always given by one particular lecturer

    2ou are re3uired to show the first4 second and third normal forms 56plain thenormalisation process used

    Ans er

    !irst Normal !orm

    7,emove repeating groups7

    1 The attribute chosen as the primary .ey is student-noThe set of attributes which repeat for each value of student-no are unit-code 4unit-name 4 and lecturer

    ! ,emoving these attributes from the full attribute set produces the relation:

    (student8no4 student8name4 course8code4 course8length)

    " The primary .ey is student-no

    (student8no4 student8name4 course8code4 course8length)

    # The primary .ey for the repeating group is unit-code This is because for each student_no the unit-code uni3uely identifies the unit-name and lecturer attributes

  • 8/12/2019 Normalisation example.pdf

    2/3

    9or e6ample4 for student 0014 unit U"# is always &atabases '' and the lecturer isalways rown

    + The new relation is:

    (student8no4 unit8code4 unit8name4 lecturer)

    % The attribute unit-code is not uni3ue in this relation and so the .ey of this relationis (student8no4 unit8code)

    (student8no4 unit8code4 unit8name4 lecturer)

    $ There are no more repeating groups

    The first normal form relations are:

    student1(student8no4 student8name4 course8code4 course8length)

    ta.es1(student8no4 unit8code4 unit8name4 lecturer)

    Second Normal !orm

    7,emove partial dependencies7

    The student1 relation does not have a composite primary .ey and4 therefore4 cannotcontain partial dependencies The takes1 relation has the following dependencies:

    student8no4 unit8code 8; unit8name4 lecturer The primary .ey determines all attributes

    unit8code 8;unit8name 5ach unit has a name

    unit8code 8; lecturer 5ach unit is taught by the same lecturer

    Therefore4 a partial dependency e6ists between unit-code and unit-name and lecturer ,emoving the partial dependencies from takes1 (but not changing the .ey of takes1 )

    produces the relations:

    ta.es (student8no4 unit8code)

    unit (unit8code4 unit8name4 lecturer)

    The second normal form relations are:

    student (student8no4 student8name4 course8code4 course8length)

    ta.es (student8no4 unit8code)

    unit (unit8code4 unit8name4 lecturer)

  • 8/12/2019 Normalisation example.pdf

    3/3

    "hird Normal !orm

    7,emove transitive dependencies7

    The student2 relation has the following functional dependencies:

    student8no 8; student8name4 course8code4course8length The primary .ey determines all attributes

    course8code 8; course8length The course length is determined by thecourse

    Therefore4 the following transitive dependency e6ists:

    student8no 8; course8code 8; course8length

    ,emoving this transitive dependency from student2 produces the following relations:

    student!(student8no4 student8name4 course8code)

    course!(course8code4 course8length)

    The takes2 relation contains no non8.ey attributes and so contains no transitivedependencies The unit2 relation contains the following dependencies:

    unit8code 8; unit8name4 lecturer The primary .ey determines all attributes

    Therefore4 there are no transitive dependencies in unit2 The set of third normal formrelations are:

    student!(student8no4 student8name4 course8code)

    course!(course8code4 course8length)

    ta.es!(student8no4 unit8code)

    unit!(unit8code4 unit8name4 lecturer)