This action might not be possible to undo. Are you sure you want to continue?
Presented By: Mike Hillyer Mike Zinner and The MySQL Workbench Team
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
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
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
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
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++
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
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.
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
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
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
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.
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.
The Normal Forms
First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF)
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
Second Normal Form (2NF)
Requires that all fields relate to an entire composite key, not just parts. (The Whole Key)
Reviewer_ID First_Name 1 Mike
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 1
123 Main Street Santa Clara
City Santa Clara
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
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.
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.
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 -->
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
Managing Schema Privileges
Add Users to design to manage their privileges Add Roles to simply management of privileges
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
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
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
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
Any Questions? Ask now or catch us during the conference!
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