KEMBAR78
Databases: Normalisation | PPT
Normalisation
Normalisation Normalisation is a process by which data structures in a relational database are as efficient as possible, including the elimination of redundancy, the minimisation of the use of null values and the prevention of the loss of information.
Aims of Normalisation Normalisation ensures that the database is structured in the best possible way. To achieve control over data redundancy. There should be no unnecessary duplication of data in different tables. To ensure data consistency. Where duplication is necessary the data is the same. To ensure tables have a flexible structure. E.g. number of classes taken or books borrowed should not be limited. To allow data in different tables can be used in complex queries.
Duplication vs Redundant Data Duplicated Data: When an attribute has two or more identical values Redundant Data: If you can delete data with a loss of information
Stages of Normalisation First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF) Boyce-Codd Normal Form (BCNF) Fourth Normal Form (4NF) Fifth Normal Form (5NF)
 
First Normal Form A table is in its first normal form if it contains no repeating attributes or groups of attributes
Non-Normalised Table STUDENT
First Normal Form To convert data for unnormalised form to 1NF, simply convert any repeated attributes into part of the candidate key STUDENT( Number , Name, Classes) STUDENT( Number , Name,  Classes )
First Normal Form STUDENT
Over to you...
Second Normal Form A table is in the second normal form if it's in the first normal form AND no column that is not part of the primary key is dependant only a portion of the primary key
Second Normal Form The concept of functional dependency in central to normalisation and, in particular, strongly related to 2NF.
Functional Dependency If ‘X’ is a set of attributes within a relation, then we say ‘A’ (an attribute or set of attributes), is functionally dependant on X, if and only if, for every combination of X, there is only one corresponding value of A We write this as : X -> A
Table in 1NF
Functional Dependency It is clear that : RefNo -> Name, Address, Status or, most correctly,  AccNo, RefNo -> Name, Address, Status
Second Normal Form
Over to you...
Table in Second Normal Form
Third Normal Form A table is in the third normal form if it is the second normal form and there are no  non-key columns  dependant on  other non-key columns  that could not act as the primary key.
Table in Second Normal Form
Table in Third Normal Form
Boyce-Codd Normal Form All attributes in a relation should be dependant upon the key, the whole key and nothing but the key
Important Papers E.F.Codd ‘ A Relational Model for Large Shared Data Banks’  CACM 13(6) June 1970  E.F. Codd ‘ Extending the Database Relational Model to Capture More Meaning’  ACM Transactions on Database Systems, 4(4), December 1979
Table in Third Normal Form
Redundancy in 3NF The combination of ROOM, TIME is unique to each tuple, no room is used twice at the same time (thus it is in 3NF). But, we know there is a redundancy in that ROOM depends LECTURER, therefore, we split the table...
Tables in BCNF
Difference between BCNF and 3NF Most relations in 3NF are also in BCNF, the only time this may not be true is when there is more than one candidate key for a relation and at least one of  is composite.
Fourth  Normal Form Fourth normal form (or 4NF) requires that there be no non-trivial multivalued dependencies of attribute sets on something other than a superset of a candidate key. A table is said to be in 4NF if and only if it is in the BCNF and multivalued dependencies are functional dependencies. The 4NF removes unwanted data structures: multivalued dependencies.
Fifth  Normal Form Fifth normal form (5NF and also PJ/NF) requires that there are no non-trivial join dependencies that do not follow from the key constraints. A table is said to be in the 5NF if and only if it is in 4NF and every join dependency in it is implied by the candidate keys.
Domain/Key Normal  Form Domain/key normal form (or DKNF) requires that the database contains no constraints other than domain constraints and key constraints.

Databases: Normalisation

  • 1.
  • 2.
    Normalisation Normalisation isa process by which data structures in a relational database are as efficient as possible, including the elimination of redundancy, the minimisation of the use of null values and the prevention of the loss of information.
  • 3.
    Aims of NormalisationNormalisation ensures that the database is structured in the best possible way. To achieve control over data redundancy. There should be no unnecessary duplication of data in different tables. To ensure data consistency. Where duplication is necessary the data is the same. To ensure tables have a flexible structure. E.g. number of classes taken or books borrowed should not be limited. To allow data in different tables can be used in complex queries.
  • 4.
    Duplication vs RedundantData Duplicated Data: When an attribute has two or more identical values Redundant Data: If you can delete data with a loss of information
  • 5.
    Stages of NormalisationFirst Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF) Boyce-Codd Normal Form (BCNF) Fourth Normal Form (4NF) Fifth Normal Form (5NF)
  • 6.
  • 7.
    First Normal FormA table is in its first normal form if it contains no repeating attributes or groups of attributes
  • 8.
  • 9.
    First Normal FormTo convert data for unnormalised form to 1NF, simply convert any repeated attributes into part of the candidate key STUDENT( Number , Name, Classes) STUDENT( Number , Name, Classes )
  • 10.
  • 11.
  • 12.
    Second Normal FormA table is in the second normal form if it's in the first normal form AND no column that is not part of the primary key is dependant only a portion of the primary key
  • 13.
    Second Normal FormThe concept of functional dependency in central to normalisation and, in particular, strongly related to 2NF.
  • 14.
    Functional Dependency If‘X’ is a set of attributes within a relation, then we say ‘A’ (an attribute or set of attributes), is functionally dependant on X, if and only if, for every combination of X, there is only one corresponding value of A We write this as : X -> A
  • 15.
  • 16.
    Functional Dependency Itis clear that : RefNo -> Name, Address, Status or, most correctly, AccNo, RefNo -> Name, Address, Status
  • 17.
  • 18.
  • 19.
    Table in SecondNormal Form
  • 20.
    Third Normal FormA table is in the third normal form if it is the second normal form and there are no non-key columns dependant on other non-key columns that could not act as the primary key.
  • 21.
    Table in SecondNormal Form
  • 22.
    Table in ThirdNormal Form
  • 23.
    Boyce-Codd Normal FormAll attributes in a relation should be dependant upon the key, the whole key and nothing but the key
  • 24.
    Important Papers E.F.Codd‘ A Relational Model for Large Shared Data Banks’ CACM 13(6) June 1970 E.F. Codd ‘ Extending the Database Relational Model to Capture More Meaning’ ACM Transactions on Database Systems, 4(4), December 1979
  • 25.
    Table in ThirdNormal Form
  • 26.
    Redundancy in 3NFThe combination of ROOM, TIME is unique to each tuple, no room is used twice at the same time (thus it is in 3NF). But, we know there is a redundancy in that ROOM depends LECTURER, therefore, we split the table...
  • 27.
  • 28.
    Difference between BCNFand 3NF Most relations in 3NF are also in BCNF, the only time this may not be true is when there is more than one candidate key for a relation and at least one of is composite.
  • 29.
    Fourth NormalForm Fourth normal form (or 4NF) requires that there be no non-trivial multivalued dependencies of attribute sets on something other than a superset of a candidate key. A table is said to be in 4NF if and only if it is in the BCNF and multivalued dependencies are functional dependencies. The 4NF removes unwanted data structures: multivalued dependencies.
  • 30.
    Fifth NormalForm Fifth normal form (5NF and also PJ/NF) requires that there are no non-trivial join dependencies that do not follow from the key constraints. A table is said to be in the 5NF if and only if it is in 4NF and every join dependency in it is implied by the candidate keys.
  • 31.
    Domain/Key Normal Form Domain/key normal form (or DKNF) requires that the database contains no constraints other than domain constraints and key constraints.