210 likes | 527 Views
Normalisation. Ham Ham’s Hammy Club. Introduction. What is normalisation? “a technique for designing relational database tables to minimize duplication of information and, in so doing, to safeguard the database against certain types of logical or structural problems” wikipedia.com.
E N D
Normalisation Ham Ham’s Hammy Club
Introduction • What is normalisation? “a technique for designing relational database tables to minimize duplication of information and, in so doing, to safeguard the database against certain types of logical or structural problems” wikipedia.com
Ham Ham’s Hammy Club – Customer Record I’m kind of a big deal! MemberID: Initial: Surname: Title: Sex: Postcode: Tel No: Hammy Details:
Ham Ham’s Hammy Club – Customer Record I’m kind of a big deal! MemberID: 0001 Initial: A Surname: Dolinski Title: Mr Sex: Male Postcode: HA1 HA1 Tel No: 0123456789 Hammy Details:
Relationships • Hamster can have one owner • Owners can have many hamsters Hamster Owner
Relationships • A hamster can only be one breed • A breed can have many hamsters Hamster Breed
Relationships Owner Hamster Breed
Ham Ham’s Hammy Club – Customer Record I’m kind of a big deal! MemberID: 0001 Initial: A Surname: Dolinski Title: Mr Sex: Male Postcode: HA1 HA1 Tel No: 0123456789 Hammy Details: We can see we already have issues with repeated data!
Example Data Customer information is repeated
Example Data Breed information is repeated
Normalisation Rules • 1NF • No repeating attributes and primary key of non repeating data must be placed in table of repeating data. • 2NF • Look for non-key attributes that depend upon all the attributes in the compound primary keys i.e. does the attribute depend on both primary keys? • 3NF • Look for non-key attributes that depend upon other non-key attributes.
1nf – Apply Rules In some cases, you may need to add a new field to make a compound primary key.
2nf – Apply Rules This fixes the many-to-many problem!
3nf – Apply Rules Here we have a foreign key – a non-primary key that links to a primary key in another table.
Remember!! • You don’t actually need to know how to normalise a database. It’s useful to know though because you’ll have a better understanding of it – it’ll also help in coursework! • However, you need to know the advantages of doing so and you’ll need to know the rules.