Download presentation
Presentation is loading. Please wait.
Published byPhilippa Stafford Modified over 9 years ago
1
1 Normalization Normalization intro Normalization intro First normal form (1NF) First normal form (1NF) Second normal form (2NF) Second normal form (2NF) Third normal form (3NF) Third normal form (3NF) Denormalization Denormalization Beyond normalization Beyond normalization Can be skipped in chapter 8 Can be skipped in chapter 8 Steen Jensen, autumn 2013
2
2 Normalization - introduction To ensure that the database is constructed appropriately (consistent design), normalization rules are used 6 normalization rules exist (normal forms) – normally only the 3 first are used, which have a practical importance Normalization first originated along with relational databases – E. F. Codd (IBM) in 1969
3
All attributes must be dependent of the primary key No repeating fields or composite fields Owner1-4 are repeating and are not dependent of the primary Solution: Owner1-4 are deleted, and a new table (entity) is made (CarUser) Car Registration Model Colour NumberDoors Owner1 Owner2 Owner3 Owner4 CarUser Registration UserId SoldDate ManufactureDate User UserId Name Street ….. ZipCode PostalDistrict 3 First normal form (1NF) – example 1
4
4 First normal form (1NF) – example 2
5
By compound primary keys all other attributes must be equally dependent of both parts of the key ManufactureDate is only dependent of Registration Solution: ManufactureDate is moved to Car CarUser Registration UserId SoldDate ManufactureDate 5 Second normal form (2NF)
6
No attribute must be more dependent of other attributes than the primary key Derived data is not allowed User UserId Name Street ….. ZipCode PostalDistrict 6 Third normal form (3NF) – example 1 User UserId Name Street ….. ZipCode District ZipCode PostalDistrict
7
Derived data is not allowed – just delete the column (attribute) 7 Third normal form (3NF) – example 2
8
Sometimes denormalization can actually be a good idea: If including extra columns (attributes) can dramatically reduce response time for queries When storing historical data (store data in fewer tables) The fewer tables that have to be joined, the easier for users to do their own reports 8 Denormalization
9
Even though normalization is important, it isn’t everything! Keep it simple – try avoiding complex solutions Choose the right data types (“wasted space is wasted speed), e.g. To store months (1-12) a tinyint would be ideal (not an int) “Are we going to need that information later?” – if in doubt, just keep it! 9 Beyond normalization
10
Page 270 – 290 + 293bot – 302top: Other normal forms (beyond third form: academic) Understanding relationships: already covered Diagramming databases + Drawing up a quick example: we use Dia (or similar) 10 Can be skipped in chapter 8
11
Take a look at exercise 1 page 302 in SQL Server Try to make your solution without looking at the answer at the back of the book When you have finished, compare your solution with the answer on page 788bot – 789top 11
12
Take a look at your relational model for Amazon Try to run your model through the three normal forms Is it ok, or do you need to change something? 12
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.