Download presentation
Presentation is loading. Please wait.
Published byPiers Williams Modified over 8 years ago
1
NORMALISATION OF DATABASES
2
WHAT IS NORMALISATION? Normalisation is used because Databases need to avoid have redundant data, which makes it inefficient. They also need to be easy to maintain, and logically this means splitting data up to make it easier to use. “Normalisation usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions, and modifications to a field can be made and the propagated through the rest of the database via the relationships”
3
Over time rules have developed that allows a Database to be designed with more levels of efficiency. These sets are called the Normalisation Forms and are numbered 0 to 5. The short hand for these are 0NF, 1NF, 2NF, 3NF, 4NF, 5NF. However, only the first, second, and third need to be known. These are only guidelines however. A unormalised database is a 0NF
4
ATOMIC DATA Atomic – The word used to describe an item that can no longer be broken down Examples National Insurance Number – NY344599 ISBN Book Reference – 1-931841-62-4 Stock Code – PN10B First Name – John Last Name - Smith
5
1NF NORMALISATION 1NF Normalisation has certain rules. These are: -There are no columns with repeated or similar data. -Each Data item is Atomic. -Each row is unique i.e. it has a Primary Key. -Each field has a unique name. IDFirst NameLast NameTelephoneTelephone 2Telephone 3 1PeterDavies012345678951415627286253846281 IDNameTelephoneTelephone 2Telephone 3 1Peter Davies012345678951415627286253846281 TitleFirst NameLast NameTelephoneTelephone 2Telephone 3 MrPeterDavies012345678951415627286253846281 IDFirst NameLast NameTelephone 1PeterDavies012345678951415627286253846281
6
2NF NORMALISATION Most Tables have one single attribute, a primary key. But sometimes there can be a compound key, made of more than one attribute. In this example, the primary key is both Venue and Artist. The Rules for 2NF are: -The table must be in first normal form -Non-Key Attributes must depend on every part of the primary key. For example, the Style depends on the Artist, not the Venue. So, we would take Style out, and make another table with Artist as its primary key and Style, and link it back to the original table. VenueArtistAttendanceProfitStyle WembleyGirls Aloud5300012334Girl Band NECLeona Lewis4500066433Female Soloist
7
3NF NORMALISATION The rules of 3NF are: -It is already in 2NF -There are no non-key attributes that depend on another non-key attribute For example: The Country is redundant data, which can be found by looking simply at the city, therefore Country can be removed, and we can create another table with City as a primary key, and country, and link it back to the original. VenueArtistAttendanceProfitCityCountry WembleyGirls Aloud5300012334LondonUK NECLeona Lewis4500066433BirminghamUK
8
BENEFITS OF NORMALISATION 1.The Database does not have redundant data, so it is smaller in size so less money will have to be spent on storage 2.Because there is less data to search through, it is much faster to run a query 3.Because there is no data duplication, there is better data integrity and less risk of mistakes 4.Because of the lack of duplication of data, there is less chance of storing two different copies of the data 5.One change can be made which will be instantly cascaded across related records
9
DISADVANTAGES OF NORMALISATION 1.You need to be careful when making Data Atomic. It could change something or make something incorrect to split it up. 2.You could end up with more tables than a unormalised database. 3.The more tables, and the more complex a database, the slower queries are able to run. 4.It is necessary to assign more relationships to interact with more tables. 5.With more tables, setting up queries could become complex.
10
EXAM QUESTIONS Structured Query Language (SQL) is used with Databases. In a supermarket, the following SQL may be used. [Q9 JAN 2011] SELECT StockNo, Quantity, Price FROM Stock WHERE Quantity < 100 ORDER BY Price DESC 1. From this, state the name of one attribute. [1] One attribute would be Quantity. 2. State the name of one table. [1] The table is Stock. 3.Describe the purpose of the code. [3] The purpose of this code is to show the user any items in the stock that there are less than 100 of.
11
Draw an E-R diagram for the following: A to B is a one to one relationship B to C is a one to many relationship C to D is a many to one relationship ABCD
12
A school uses a relational database. Information is held in a table STUDENTS and a table SUBJECTS. [Q10 JUN 2011] 1. State the relationship between STUDENTS and SUBJECTS [1] The relationship is many to many 2. Explain the consequences of this relationship [3] The consequences is that the database cannot be Normalised to the Third Normal Form due to having a many to many relationship 3. The relationship between Student and Tutor is shown. State the relationship [1] The relationship is a many to one relationship
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.