1.2. Normalisation

Database Normalisation




  • Normalisation is the process of organising data into tables so that the results of using the database are unambiguous and as intended. 
    • It is a refinement process that aims to reduce data redundancy.
  • Normalisation results in a database that is more efficient but more complex because data is separated into more tables
    • For example, Table 2.2 is used to keep track of customer purchases and the price of the products. 
      • If you deleted a customer, you would also delete a price.
      • Normalising would solve this problem by dividing this table into two tables: a table about each customer and a product they had bought and a table about each product and its price.
      • Making additions or deletions to either table would not affect the other using the database are unambiguous and as intended. 
      • It is a refinement process that aims to reduce data redundancy. 

Summary

1st Normal Form (1NF)
  • Each field contains a single data item - all data values are atomic
    • e.g. Customer Name becomes Customer First Name and Customer Last Name
    • or Address is split out into component bits
  • There can be no multiple items in a single record - no repeating groups
    • If there are repetitions, then strip the repeating parts out into another table and link it back to the original table.

  • For each table (incuding new ones created by this step)
    • Each field has a unique name
    • It has a primary key

1NF

2nd Normal Form (2NF)

  • Must be 1NF, plus....
  • Every non-prime (non-key) attribute of the table is dependent on the whole of every candidate key, i.e. all parts of the primary key.  
    • That is, every column depends on the entire primary key.

    • What is a Non Key Attribute?
      • A KEY ATTRIBUTE is one which is a PRIMARY KEY or part of a COMPOSITE PRIMARY KEY
      • So, therefore, the NON-KEY ATTRIBUTES in a table are the other attributes in the table (i.e. those that aren't a primary key or part of a composite primary key.)
    • SO...if a table has NO composite primary key, then it is therefore already in 2NF

  • plus, as a reminder (especially if you are splitting a table into smaller parts, then for each table):
    • Each field has a unique name
    • It has a primary key field

2NF

3rd Normal Form (3NF)

  • Must be 2NF, plus....
  • All non-key attributes are not dependent on any other non-key attributes
  • plus, as a reminder, for each table:
    • Each field has a unique name
    • It has a primary key field

3NF








Comments