[Year 12 IT Apps] First Normal Form

Robert Timmer-Arends timmer at westnet.com.au
Wed Nov 5 18:13:45 EST 2014


Hello all

There is one extra component to 1NF that I feel needs to be stated explicitly.The table must have a primary key; that is, a column or group of columns which uniquely identify a given row. This is important because without reference to a primary key, 2NF and 3NF are not possible.

And the definition about 'there may only be one datum' is correct as far it goes, but "16 Fred Street Melbourne 3000" can be a single datum. It depends on the design needs of the db.
It many ways I find it best to incorporate some of OO terminology - a column is equilvalent to a class, and any individual field in the column can only contain one instance of that class.

So, for example, if the column were "address" and address was defined as "street address + suburb + post code" then "16 Fred Street Melbourne 3000" is one datum (one instance of the class 'address').
Whether 'address' is further split or not has to do with search requirements, not normalisation.

So
name        phone
fred smith    345678000
                  543265465
suzy lang    101010101
(primary key = name) is NOT 1NF (repeated phone number, or two instances of phone number in the same row)
and
name        phone1        phone2
fred smith    345678000    543265465
suzy lang    101010101
(primary key = name) is NOT 1NF (different column names, but still two instances of the same class of data)
but
name        phone
fred smith    345678000
fred smith    543265465
suzy lang    101010101
(primary key = name+phone) IS 1NF (no repeating groups, but the primary key has to be extended. In a 'real db, because there could be many fred smiths and suzy langs, we would have a single ID field as a primary key, and because we most probably want to search on family name, we would probably split the name field)

Regards
Robert T-A

----- Original Message ----- 
  From: Mark 
  To: Year 12 IT Applications Teachers' Mailing List 
  Sent: Wednesday, November 05, 2014 9:39 AM
  Subject: Re: [Year 12 IT Apps] First Normal Form


  Hi Stephanie. Now you know why I bailed out when I did  :-)


  1NF is easy:
   - there must be no repeated columns (fields) e.g. Contact person 1, Contact person 2, Contact person 3.
   - there may only be one datum in any field - i.e. no "16kg" "3 minutes 56 seconds", "Large Size $4, Small $2.50", "16 Fred St, Melbourne, 3000".


  2NF problems ONLY arise if you're silly enough to use a multi-field key (e.g. using firstname & familyname to uniquely identify people in a table). 
  2NF problems never even arise if each table has its own dedicated key field (e.g. ID, account number). 


  But anyway, kids are expected to know 2NF.


  2NF requires:
  - 1NF has already been achieved.
  - Any non-key field in a table is dependent on ALL of the fields used as the primary key.


  As usual, this means as little as American football, so an example is needed.


  There's a table with the following fields. 1NF has already been achieved.


  StudentID
  SubjectID
  Mark
  SubjectName


  e.g. (Hope the formatting is not mangled - wish I could insert a table)
  STUDENTID     SUBJECTID    Mark    SubjectName
  SMI0001       ENG          A+      English
  SMI0001       MA           B       Maths
  FRE0002       ENG          C       English


  The table's key is STUDENTID and SUBJECTID (together) to uniquely identify each record in the table.


  The (non-key) MARK field is dependent on both STUDENTID and SUBJECTID - i.e. to find out what a mark refers to, you need to know both the student and subject.


  However, the (non-key) SUBJECTNAME field is dependent only the SUBJECTID - i.e. to find out what a subject name refers to, you only need the SUBJECTID. You don't need the STUDENTID.


  So the (non-key) SUBJECTNAME field is dependent on part of the key (SUBJECTID) but not the whole key (STUDENTID+SUBJECTID).


  So it fails 2NF.


  To fix the problem, the table must be broken into two  - 
  - MARKS_TABLE with STUDENTID+SUBJECTID as its key. It also contains the MARK non-key field.
  - SUBJECTS_TABLE with SUBJECTID (primary key) and non-key SUBJECTNAME.


  You then create a relationship between the MARKS table and the SUBJECTS table using their primary keys as the related fields.
  Now, in the MARKS table, a Mark is dependent upon the entire key in its table (STUDENTID+SUBJECTID).
  In the SUBJECTS table, a subject name is dependent on the entire key in its table (SUBJECTID).


  Bingo. 2NF.


  Hope that helps.












  On 5 November 2014 08:53, Stephanie Polan <pos at mckinnonsc.vic.edu.au> wrote:

    Good Morning everyone,


    I know this is crazy... but my 12's are making me crazy, does anyone have any simple blunt help for Normal Form's ie 1NF 2NF. I've gone through my explanations and Mark Kelly's slide show and my patience and my students are still asking for clarification because of course they can learn and remember it for Friday!!! 


    Thanks in advance
    Stephanie Polan



    -- 

    Miss Polan
    McKinnon SC

    _______________________________________________
    http://www.edulists.com.au - FAQ, resources, subscribe, unsubscribe
    IT Applications Mailing List kindly supported by
    http://www.vcaa.vic.edu.au/vce/studies/infotech/itapplications3-4.html - Victorian Curriculum and Assessment Authority <br>
    http://www.vitta.org.au  - VITTA Victorian Information Technology Teachers Association Inc <br>
    http://www.swinburne.edu.au/ict/schools - Swinburne University






  -- 



  Mark Kelly
  mark AT vceit DOT com
  http://vceit.com


  I love the sound of people's voices after they stop talking.






------------------------------------------------------------------------------


  _______________________________________________
  http://www.edulists.com.au - FAQ, resources, subscribe, unsubscribe
  IT Applications Mailing List kindly supported by
  http://www.vcaa.vic.edu.au/vce/studies/infotech/itapplications3-4.html - Victorian Curriculum and Assessment Authority <br>
  http://www.vitta.org.au  - VITTA Victorian Information Technology Teachers Association Inc <br>
  http://www.swinburne.edu.au/ict/schools - Swinburne University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/itapps/attachments/20141105/fda5cefc/attachment.html 


More information about the itapps mailing list