Download presentation
Presentation is loading. Please wait.
Published byPeregrine Stokes Modified over 9 years ago
1
Database Design Normalisation
2
Last Session Looked at: –What databases were –Where they are used –How they are used
3
Normalisation We have just done the top down Entity Relationship diagram method We now need to try the bottoms up approach called normalisation
4
Draw up a typical paper record for the project you are converting to a database In this example we are using records of potential students enquiring about courses Course NameBTEC for IT Practitioners Length2 years TutorLen Shand LocationMain campusLocation code001 Level3 DateNameAddressDOBAction 10/10/04W RooneyManchester5/08/87Send details 19/10/04A WengerLondon5/3/47Tutor to call 20/10/04A FergusonManchester28/4/42Send details
5
Draw up a landscape table with 5 columns 0NF1NF2NF3NFTable names
6
List all the attributes from the paper record in the 0NF column 0NF1NF2NF3NFTable names
7
List all the attributes from the paper record in the 0NF column 0NF1NF2NF3NFTable names Course Name Length Tutor Location Location Code Level Date Name Address DOB Action
8
Identify the group or groups of attributes that are/or can be repeated on the paper record. Put a bracket around all of them 0NF1NF2NF3NFTable names Course Name Length Tutor Location Location Code Level (Date Name Address DOB Action)
9
Add a primary key for the repeating group and for the group only entered once. 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action)
10
Copy the non-repeating group across into the 1NF column. This group is already in 1NF as it doesn’t have any brackets around it. 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action) CourseID Course Name Length Tutor Location Location Code Level
11
1.Move the repeating group across into the 1NF column, making sure it is separated from the group already there. 2.Add the key from the non-repeating group to it and remove the brackets 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action) CourseID Course Name Length Tutor Location Location Code Level EnquirerID CourseID Date Name Address DOB Action
12
This is now in first normal form There are no repeating groups The second group has a compound primary key (EnquirerID/CourseID) This corresponds to 2 tables All records can be recombined into one record by using the keys To put the database into 2NF we need to make sure it is in 1NF and all the non-key attributes depend entirely on the primary key
13
Move groups which only have a simple primary key into the 2NF column 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action) CourseID Course Name Length Tutor Location Location Code Level EnquirerID CourseID Date Name Address DOB Action CourseID Course Name Length Tutor Location Location Code Level
14
Next we identify those attributes in the other group that do not depend on both keys. 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action) CourseID Course Name Length Tutor Location Location Code Level EnquirerID CourseID Date Name Address DOB Action CourseID Course Name Length Tutor Location Location Code Level
15
Move the non-key attributes that depend on only one key across to the 2NF column. Then copy the attribute they do depend on into the group with them. 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action) CourseID Course Name Length Tutor Location Location Code Level EnquirerID CourseID Date Name Address DOB Action CourseID Course Name Length Tutor Location Location Code Level EnquirerID Name Address DOB
16
The remaining group (EnquirerID, CourseID, Date and Action are then moved into the 2NF column and given a unique ID. In our case we call it the EnquiryID. 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action) CourseID Course Name Length Tutor Location Location Code Level EnquirerID CourseID Date Name Address DOB Action CourseID Course Name Length Tutor Location Location Code Level EnquirerID Name Address DOB EnquiryID EnquirerID CourseID Date Action
17
Look at attributes that are not part of a key and work out if they depend on another attribute and not the primary key of the group they are in. 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action) CourseID Course Name Length Tutor Location Location Code Level EnquirerID CourseID Date Name Address DOB Action CourseID Course Name Length Tutor Location Location Code Level EnquirerID Name Address DOB EnquiryID EnquirerID CourseID Date Action
18
Move Location across into its own group and copy Location Code into it as a primary key. Then Location Code is also left as a foreign key in the CourseID group. 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action) CourseID Course Name Length Tutor Location Location Code Level EnquirerID CourseID Date Name Address DOB Action CourseID Course Name Length Tutor Location Location Code Level EnquirerID Name Address DOB EnquiryID EnquirerID CourseID Date Action CourseID Course Name Length Tutor Location Code Level Location Code Location EnquirerID Name Address DOB EnquiryID CourseID EnquirerID Date Action
19
The final task is to give meaningful names to each group, which are now the tables to go into the database. 0NF1NF2NF3NFTable names CourseID Course Name Length Tutor Location Location Code Level (EnquirerID Date Name Address DOB Action) CourseID Course Name Length Tutor Location Location Code Level EnquirerID CourseID Date Name Address DOB Action CourseID Course Name Length Tutor Location Location Code Level EnquirerID Name Address DOB EnquiryID EnquirerID CourseID Date Action CourseID Course Name Length Tutor Location Code Level Location Code Location EnquirerID Name Address DOB EnquiryID CourseID EnquirerID Date Action Course Location Enquirer Enquiry
20
The End The database is now in third normal form It is possible that the design arising from the two methods differs. It is then up to the database designer to decide which solution to implement.
21
Exercise Use the method above to normalise the following bank customer record –The account number is unique –The balance only depends on the account number CustomerID43543 SurnameJones PostcodeBA3 6TH Phone number654321 Account NumberAccount TypeDescriptionBalance 22442546GoldSavings£10.00 44342322PlatinumCurrent£100.00 77164645SilverInternet£500.00
22
Assignment scenario You have been asked to provide a solution to the problem of vehicle rentals at Joe’s Vehicle Rentals. The current system consists of paper files for the vehicles and the people who are renting them. The specifications for the project are: Manage rentals – Record new rentals – Record the returned vehicle – Update rentals if they are extended Keep vehicle details –Add new vehicles (by make, model and year) –Make vehicles inactive when they have reached 100000 miles – Keep vehicle attributes – Add new vehicle attributes (number of seats, engine size and fuel type) Include a table to hold the daily, weekly and monthly rental costs Keep customer details – Add new customers – Delete old customers (after 1 year and 1 day if no activity) – Update customer details Produce lists of vehicles on loan to a particular customer and when the vehicle is due back Produce lists of vehicles still to be rented (available for rent) Produce alphabetical list (by customer surname) of vehicles rented by customer Produce a printed rental agreement for the customer to sign.
23
Assignment task TASK 1 (P1, M1, D1) You have to write a section in the design documentation which discusses the choice of software you will use for your implementation. This should be no more than 500 words and should be illustrated with diagrams. You should: Explain how a solution could be implemented using a spreadsheet Discuss the advantages and disadvantages of the spreadsheet for this particular problem Explain how a solution could be implemented using a database Discuss how the purpose and features of a relational database solution can overcome some of the problems inherent in the spreadsheet solution Make sure you include an explanation of the use of primary and foreign keys in your explanation You do not need to discuss the choice of application (eg Access versus MySQL)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.