SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Database Normalization PHP Quebec 2005 Mike Hillyer – MySQL AB
About Me ,[object Object],[object Object],[object Object],[object Object],[object Object],Mike Hillyer, BSc
About You ,[object Object],[object Object],[object Object],[object Object],[object Object],How many of you…
About This Session ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What Is Database Normalization? ,[object Object],[object Object],[object Object],[object Object]
What are the Benefits of Database Normalization? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What are the Normal Forms? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Our Table [email_address] 403-555-1111 403-555-1919 Ray Smith [email_address] [email_address] 403-555-1313 403-555-1919 Tom Jensen [email_address] [email_address] 403-555-1919 403-555-1717 Mike Hillyer email2 email1 phone2 phone1 name
First Normal Form ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
One Solution ,[object Object],[object Object],[object Object],Smith Smith Jensen Jensen Hillyer Hillyer last_name 403-555-1111 Ray [email_address] 403-555-1313 Tom [email_address] 403-555-1919 Mike [email_address] 403-555-1919 Ray [email_address] 403-555-1919 Tom [email_address] 403-555-1717 Mike email phone first_name
Satisfying 1NF
Forming Relationships ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Joining Tables
Our User Table Smith Jensen Hillyer last_name Documentation CPNS Ray Finance CPNS Tom Documentation MySQL Mike department company first_name
Second Normal Form ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Satisfying 2NF
Third Normal Form ,[object Object],[object Object],[object Object],[object Object],[object Object]
Satisfying 3NF
Finding Balance
Joining Tables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
De-Normalizing Tables ,[object Object],[object Object],[object Object],[object Object]
Conclusion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
QUESTIONS? Feel free to ask now or find me after this session!
Book Draw! Stick around and win a book!

Weitere ähnliche Inhalte

Was ist angesagt?

stem and leaf diagrams
 stem and leaf diagrams stem and leaf diagrams
stem and leaf diagrams
blockmath
 
Inner Pages Research
Inner Pages ResearchInner Pages Research
Inner Pages Research
os99sk8
 
Stem & leaf plots + histograms
Stem & leaf plots + histogramsStem & leaf plots + histograms
Stem & leaf plots + histograms
ListeningDaisy
 

Was ist angesagt? (15)

B+tree
B+treeB+tree
B+tree
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
 
B+tree Data structures presentation
B+tree Data structures presentationB+tree Data structures presentation
B+tree Data structures presentation
 
Excel text functions
Excel text functionsExcel text functions
Excel text functions
 
stem and leaf diagrams
 stem and leaf diagrams stem and leaf diagrams
stem and leaf diagrams
 
Boxplot
BoxplotBoxplot
Boxplot
 
joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysis
 
Bootcamp sql fundamentals bootcamp_part4
Bootcamp   sql fundamentals  bootcamp_part4Bootcamp   sql fundamentals  bootcamp_part4
Bootcamp sql fundamentals bootcamp_part4
 
Inner Pages Research
Inner Pages ResearchInner Pages Research
Inner Pages Research
 
DATASTORAGE.pptx
DATASTORAGE.pptxDATASTORAGE.pptx
DATASTORAGE.pptx
 
DATASTORAGE.pdf
DATASTORAGE.pdfDATASTORAGE.pdf
DATASTORAGE.pdf
 
Stem & leaf plots + histograms
Stem & leaf plots + histogramsStem & leaf plots + histograms
Stem & leaf plots + histograms
 
Joins in dbms and types
Joins in dbms and typesJoins in dbms and types
Joins in dbms and types
 
Nikhat b+ trees ppt
Nikhat b+ trees pptNikhat b+ trees ppt
Nikhat b+ trees ppt
 
Fraction
FractionFraction
Fraction
 

Andere mochten auch (6)

Normalisation lesson plan
Normalisation   lesson planNormalisation   lesson plan
Normalisation lesson plan
 
Sql join
Sql  joinSql  join
Sql join
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
 
MS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining Databases
 
A place in the choir
A place in the choirA place in the choir
A place in the choir
 
Sung
SungSung
Sung
 

Ähnlich wie Database normalisation

Database Design Process
Database Design ProcessDatabase Design Process
Database Design Process
mussawir20
 
Normalisation - 2nd normal form
Normalisation - 2nd normal formNormalisation - 2nd normal form
Normalisation - 2nd normal form
college
 
Ms access tutorial
Ms access tutorialMs access tutorial
Ms access tutorial
minga48
 
Advance sqlite3
Advance sqlite3Advance sqlite3
Advance sqlite3
Raghu nath
 

Ähnlich wie Database normalisation (20)

Year 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st TermYear 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st Term
 
Persentation of SAD 2
Persentation of SAD 2Persentation of SAD 2
Persentation of SAD 2
 
normaliztion
normaliztionnormaliztion
normaliztion
 
Database Normalization.docx
Database Normalization.docxDatabase Normalization.docx
Database Normalization.docx
 
Database Design Process
Database Design ProcessDatabase Design Process
Database Design Process
 
Access 05
Access 05Access 05
Access 05
 
Intro to Data warehousing lecture 08
Intro to Data warehousing   lecture 08Intro to Data warehousing   lecture 08
Intro to Data warehousing lecture 08
 
Topics-Ch4Ch5.ppt
Topics-Ch4Ch5.pptTopics-Ch4Ch5.ppt
Topics-Ch4Ch5.ppt
 
Topics-Ch4Ch5.ppt
Topics-Ch4Ch5.pptTopics-Ch4Ch5.ppt
Topics-Ch4Ch5.ppt
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
 
Research gadot
Research gadotResearch gadot
Research gadot
 
Normalisation - 2nd normal form
Normalisation - 2nd normal formNormalisation - 2nd normal form
Normalisation - 2nd normal form
 
Ms sql server tips 1 0
Ms sql server tips 1 0Ms sql server tips 1 0
Ms sql server tips 1 0
 
Ms access tutorial
Ms access tutorialMs access tutorial
Ms access tutorial
 
Advance sqlite3
Advance sqlite3Advance sqlite3
Advance sqlite3
 
Normalization Accepted
Normalization AcceptedNormalization Accepted
Normalization Accepted
 
Feb 2nd Makeup Class
Feb 2nd Makeup ClassFeb 2nd Makeup Class
Feb 2nd Makeup Class
 
Data normailazation
Data normailazationData normailazation
Data normailazation
 
Normalization
NormalizationNormalization
Normalization
 
Lecture 6.pptx
Lecture 6.pptxLecture 6.pptx
Lecture 6.pptx
 

Mehr von suresh chaudhari (6)

Adviceforphotos jac
Adviceforphotos jacAdviceforphotos jac
Adviceforphotos jac
 
Chapter2(2)
Chapter2(2)Chapter2(2)
Chapter2(2)
 
Iotsunami
IotsunamiIotsunami
Iotsunami
 
Global warming
Global warmingGlobal warming
Global warming
 
Earthquakes
EarthquakesEarthquakes
Earthquakes
 
Database normalisation
Database normalisationDatabase normalisation
Database normalisation
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Database normalisation

Hinweis der Redaktion

  1. Mike Hillyer Technical writer for MySQL AB, MySQL Core and Pro certified. This session has been delivered to the Lethbridge MySQL Group and will also be delivered at the PHP Quebec conference.
  2. I’m Mike Hillyer from Alberta Canada. Here’s some qualifications for those who are interested.
  3. Those using another DB are forgiven ;) We’ll be started with a look at the most common model, followed by an introduction on a better approach.
  4. If you want to follow along, you can find the slides for this presentation at openwin.org, the article this session was based on is at vbmysql.com
  5. Many new database developers suffer from the ‘spreadsheet syndrome’, creating as few tables as possible, often just a single table. They place dozens of columns in their table, to try and cover every possible piece of data, even though they often leave most columns unfilled for a given row. By contrast database normalization aims to store the smallest amount of info possible in each table, leaving no columns that are filled for just a few of the rows. In fact, in a properly normalized table there should be very few empty(NULL) fields. This is accomplished by restructuring the data into multiple tables, with each table containing a subset of the information.
  6. And hey, odds are you can change more than one column, and you may have more than a million rows.
  7. Normal forms above 3NF are mainly for academics, and are not seen very often in the wild.
  8. Back to original table, our phone columns are redundant, our name field holds more than one piece of info, we have redundant email addresses. And even the cell and pager info is redundant in the sense that they are both phone numbers to reach you at.
  9. We now have three tables. In our phone table, instead of just having the phone number in a column we split it into country code, number, and extension. If we were really ambitious we could even split off the area code, but it depends on what you need to do with the data. Each table has a primary key so that each row can be uniquely identified. The email and phone tables have ID primary keys, and the user also has a user_id. I’ll talk about how to associate these tables next.
  10. Before we relate these tables, lets look at the different types of relationships that exist: In our case, the email table can just contain the user_id from the user table, indicating which user it belongs to. This will be combined with the address itself to form a composite primary key. The phone on the other hand is a many-to-many. One person can have several numbers, and multiple people can share the same number.
  11. Because we can have one phone number shared by many people, and a person can have many phone numbers, we are going to create a joining table between them. Our email addresses are considered unique, and because each address has one user, we place the primary key of the user in the email table as a foreign key.
  12. So, we need to remove the vertical redundancy of the company name, and the type column in the joining table violates 2NF, the type has more to do with the phone line than with the user and phone together.
  13. We now have a user/company table, with the department included since the department relates to the combination of user and company.
  14. There are a few places we can see potential 3NF violations: The phone extension is going to be different for each person in an office, and it not a property of the phone itself, so lets move it to the user_phone table. The email format, while often considered specific to a user, is probably more a property of the email address. Some may like text at work and tolerate HTML at home.