introduction to data modeling with mysql workbench
DESCRIPTION
This is your opportunity to become a database schema design expert! Sun/MySQL trainers will host daily workshop with a limited number of seats during the MySQL Users Conference. Make sure to put down your reservation as soon as possible not to miss the opportunity to attend this free workshop. Please see http://wb.mysql.com for more information.TRANSCRIPT
![Page 1: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/1.jpg)
Introduction to Data Modeling with MySQL WorkbenchPresented By:
Mike HillyerMike Zinner
andThe MySQL Workbench Team
1
![Page 2: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/2.jpg)
Who Are We? Mike Hillyer Former MySQL AB Technical Writer, GUI Tools http://www.mikehillyer.com
Mike Zinner Team Lead, Developer Tools http://zinner.org
Alfredo Kojima Senior Software Engineer, Developer Tools
Johannes Taxacher QA Engineer, Developer Tools
2
![Page 3: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/3.jpg)
Who Are You?
How Many Of You:
Are Here for Data Modeling? Are Here for MySQL Workbench? Are Here for Both?
Are Database Designers? Are Developers?
Have used MySQL Workbench?
Secret Plan: You are Guinea Pigs
3
![Page 4: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/4.jpg)
What is This Session About? An introductory session for those new to both data
modeling and MySQL Workbench
Covers: Designing a schema Introduction to workbench Designing a schema with WB How to normalize a schema Performance Optimizations Advanced Workbench Usage Q&A Conclusion
4
![Page 5: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/5.jpg)
Workbench Install
Go to http://dev.mysql.com/workbench/UC09Workbench.php to download installer
Alternatively collect a thumbdrive, installers are included for all supported platforms
Please raise your hand for install assistance
Windows users will need the .NET Framework 2.0 and the VS2005.net Redistributable. Both are found at microsoft.com/downloads and on the thumb drives
5
![Page 6: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/6.jpg)
Introducing MySQL Workbench
DBDesigner4 brought Mike Zinner to MySQL AB
MySQL GUI team developed Query Browser, Administrator, Windows Installer and finally MySQL Workbench
MySQL Workbench is a visual database design tool
Workbench provides tools for design, change management, documentation
Workbench is extensible using Lua, Python and C++
6
![Page 7: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/7.jpg)
MySQL Workbench Goals Productivity for MySQL Developers & DBAs Save time when working with big schemata Make it easy to visualize and tune schemata
Give Developers the tool they really need Done by developers for developers Native on each platform - best user experience!
Make MySQL easier to use GUI Tools 2nd biggest download on MySQL.com Best selling product in the MySQL online shop
7
![Page 8: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/8.jpg)
MySQL Workbench Editions MySQL Workbench OSS (Community Edition) MySQL Workbench SE (Standard Edition) $99/Developer/Year subscription
$2,500...$20,000/Company/Year for Unlimited sub.
8
![Page 9: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/9.jpg)
9
MySQL Workbench Standard Edition Commercial extension of OSS version Added features: Schema object privilege system Schema validation plugins Model reporting Online printing Reverse engineering Synchronization (against live database connections)
Purchase for annual subscription fee of $99 Downloadable from website http://mysql.com/products/workbench/features.html
9
![Page 10: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/10.jpg)
Usage Walkthough
10
![Page 11: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/11.jpg)
Exercise
Build a schema to track surveys and responses. Record surveys with descriptions Record questions, potential pre-defined multiple
choice answers, allow for written response Record responses to questions, attach them to
individual responders
11
![Page 12: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/12.jpg)
Data Types
Use Appropriate Data Type – when data type is wrong can lead not only to compromised data, but additional processing to convert the string to a numeric value prior to performing calculations
Use Appropriate Length – a length that has a max value so high would be inappropriate for data that would max out much smaller
Use Not Null – a column with NULL capability that will never contain a NULL can cause integrity issues and add unnecessary processes
12
![Page 13: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/13.jpg)
Normalize Your Schema What is Normalization?
Introduced by E.F. Codd
The modification of a schema so that it conforms to defined normal forms.
Ensuring that every non-key column relates to“The Key, The Whole Key, and Nothing But the Key”
So Help Me Codd
Makes data atomic. Reduces redundancy.
13
![Page 14: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/14.jpg)
Benefits of Normalization Decreased storage consumption. Removed redundancy means less data.
Better/Faster(/Stronger) searches. Less data to scan. Easier searches on (previously) mixed data.
Improved data integrity. When data is only in one place you only have to get
it right/fix it once.
14
![Page 15: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/15.jpg)
The Normal Forms
First Normal Form (1NF)
Second Normal Form (2NF)
Third Normal Form (3NF)
15
![Page 16: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/16.jpg)
First Normal Form (1NF)
Requires a Primary Key. (The Key) Requires that all data is atomic.
Also work on removing horizontal and vertical redundancies from your table.
Name
Mike Hillyer
ID First_Name Last_Name
1 Mike Hillyer
16
![Page 17: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/17.jpg)
Second Normal Form (2NF) Requires that all fields relate to an entire
composite key, not just parts. (The Whole Key)
Reviewer_ID First_Name Last_Name ISBN Score
1 Mike Hillyer 2233 4.5
Reviewer_ID ISBN Score
1 2233 4.5
17
![Page 18: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/18.jpg)
Third Normal Form (3NF) Requires that all fields depend directly on the primary
key, and not on other non-key fields. (And Nothing But The Key)
Address_ID Address City State Zip
1 123 Main Street Santa Clara California 90221
Zip City State
90221 Santa Clara California
18
![Page 19: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/19.jpg)
Additional Normal Forms
Boyce-Codd Normal Form Fourth Normal Form Fifth Normal Form Domain/Key Normal Form Sixth Normal Form Non-First Normal Form
http://en.wikipedia.org/wiki/Database_normalization
19
![Page 20: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/20.jpg)
By Example: User Tracking Table has no Primary Key. Name is not atomic. Table starts with all possible user
information in a single table. Phone numbers and email addresses
are horizontally redundant. Company, department, city, state, zip
are vertically redundant.
20
![Page 21: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/21.jpg)
1NF Satisfied
21
![Page 22: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/22.jpg)
2NF Satisfied
22
![Page 23: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/23.jpg)
3NF Satisfied
23
![Page 24: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/24.jpg)
Over-Normalization
24
![Page 25: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/25.jpg)
De-Normalization Start by normalizing, then watch your slow query logs
and run EXPLAIN.
De-Normalization may be needed on certain queries (joining and sorting).
Maintain data integrity with triggers.
Alternatively try using a view first to bring data together.
25
![Page 26: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/26.jpg)
Think Outside the Database Consider whether the data in question needs to be
stored in the database at all
Can/should a slow query be cached outside the database, perhaps even client-side
Recommended reading -->
26
![Page 27: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/27.jpg)
How to De-Normalize Combine one-to-many relationships - there are
times when a single column should be added to the “many” table to remove the need to have a join
Add Attributes – add additional columns to an existing table to improve performance by minimizing the need for a join
Data Snapshot - create a table that stores a snapshot of data that needs to be retrieved through multiple methods
27
![Page 28: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/28.jpg)
Managing Schema Privileges
Add Users to design to manage their privileges
Add Roles to simply management of privileges
28
![Page 29: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/29.jpg)
Maintaining Your Design
Whenever possible make your changes in the design, then update the database from Workbench
Test your changes in a staging environment first
Use the sync tool to implement changes from the design or update the design with changes made to the database
29
![Page 30: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/30.jpg)
Document Your Schema
Generate automatic documentation using DBDoc tool
Use model notes to keep track of important information
Use layers to logically group objects
Print out your schema for easy developer reference
30
![Page 31: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/31.jpg)
31
![Page 32: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/32.jpg)
Using Advanced Features
Export ORM Schemas Directly from Workbench Using Community Plugins:
http://forums.mysql.com/read.php?153,208229
Use custom Add-ons to perform new tasks:
http://dev.mysql.com/workbench//?p=190
32
![Page 33: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/33.jpg)
The Future of WB: RoadMap
WB 5.2 “Query”, Q3/09 Database querying, Administration Plugin
WB 6.0 “SQL IDE”, Q2/10 SQL Re-factoring, Query Builder
WB 6.1 “Team”, Q3/10 Workgroup support, Versioning
Coming up next: Multi RDBMS support
Logical modeling
Advanced migration
33
![Page 34: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/34.jpg)
Q & A
Any Questions?
Ask now or catch us during the conference!
34
![Page 35: Introduction to Data Modeling with MySQL Workbench](https://reader030.vdocuments.mx/reader030/viewer/2022012401/552822cb49795917048b45a0/html5/thumbnails/35.jpg)
Conclusion
Thanks for Coming!
Please check http://mikehillyer.com/presentations for the slides and recording of this presentation
Watch http://wb.mysql.com/ for news and developments
35