Professional Documents
Culture Documents
Lecture 6 Relationships and Normalisation-1
Lecture 6 Relationships and Normalisation-1
NORMALISATION 3.
4.
Each row is unique
No significance in column sequence
5. No significance in row sequence
Bamweyana Ivan
LSG: 2102
Normalisation
Normalisation
• Process of converting tables to conform to Codd’s • Database normalization is the process of organizing
relational rules the fields and tables of a relational database to
• Split tables into new tables that can be joined at query minimize redundancy and dependency.
time • Normalization usually involves dividing large tables into
• The relational join smaller (and less redundant) tables and defining
• Several levels of normalization relationships between them.
• Forms: 1NF, 2NF, 3NF, 4NF and 5NF. • The objective is to isolate data so that additions, deletions,
• Normalization creates many “expensive” joins and modifications of a field can be made in just one table
and then propagated through the rest of the database via
the defined relationships. (wikipedia)
1
10/4/2018
Normal Forms
1st Normal Form
• Normal forms are a series of developed guidelines for
• Each attribute must be atomic
ensuring that databases are normalized.
• Atomic means can not be further decomposed and simplified
• They are numbered from one (the lowest form of • No repeating columns within a row.
normalization, referred to as first normal form or 1NF) • No multi-valued columns.
through five (fifth normal form or 5NF). • 1NF simplifies attributes
• In practical applications, you'll often see 1NF, 2NF and 3NF
• A relation is said to be in 1NF if it contains no
along with the occasional 4NF. Fifth normal form is very
rarely seen.
non-atomic values and each row can provide
a unique combination of values
• Occasionally necessary to stray from them to meet practical
• Queries become easier.
business requirements.
2NF
Functional Dependence
Employee (1NF)
Employee (1NF) emp_no name dept_no dept_name skills
1 Kevin Jacobs 201 R&D C
emp_no name dept_no dept_name skills 1 Kevin Jacobs 201 R&D Perl
1 Kevin Jacobs 201 R&D C 1 Kevin Jacobs 201 R&D Java
1 Kevin Jacobs 201 R&D Perl 2 Barbara Jones 224 IT Linux
1 Kevin Jacobs 201 R&D Java 2 Barbara Jones 224 IT Mac
2 Barbara Jones 224 IT Linux 3 Jake Rivera 201 R&D DB2
2 Barbara Jones 224 IT Mac 3 Jake Rivera 201 R&D Oracle
3 Jake Rivera 201 R&D DB2 3 Jake Rivera 201 R&D Java
3 Jake Rivera 201 R&D Oracle
3 Jake Rivera 201 R&D Java
2
10/4/2018
• Insert Anomaly - adding new values. E.g., inserting a new department does not
require the primary key of emp_no to be added.
• Update Anomaly - multiple updates for a single name change causes
performance degradation. E.g., changing IT dept_name to IS
• Delete Anomaly - deleting wanted information. E.g., deleting the IT department
removes employee Barbara Jones from the database
This is the purpose of the 3NF – to maintain data integrity!
(emp_no -> dept_no , dept_no -> dept_name, thus emp_no -> dept_name)
3
10/4/2018
Normal Forms-summary
Normal Forms-summary
• First Normal Form
• Table has rows and columns • Third Normal Form
• Every row is unique • 3NF is also in 2NF (which is also in 1NF!)
• Only one value is in each location • All columns that are not primary keys must depend on the primary key
• Primary key is defined • In 3NF, all columns depend on the primary key only
• i.e. it is not possible to use any other (non-PK) column to find the value
• Second Normal Form of a column
• Table should be in 1NF
• Columns that are not the primary key must be totally dependant on
the primary key
• Each column is only searchable through its table’s primary key
• This further reduces redundancy and manages delete, update and
insert anomalies