August 25, 2015 Sam Siewert
CS317 File and Database Systems
Using MySQL Workbench [PRClab]
http://dev.mysql.com/downloads/workbench
Resources for MySQL-Workbench Examine Use of MySQL Workbench to Go Between EER and Schemas Forward Engineer – From EER Entered into mysql-workbench to PRClab DBMS – Creates Tables, Keys, Views, etc. from Design
Reverse Engineer – From DBMS to EER in myql-workbench – Useful to Understand and Improve existing DBMS
Workbench Tutorial - https://www.youtube.com/watch?v=X_umYKqKaF0
Sam Siewert 2
Methods to Connect to MySQL MySQL-Workbench must CONNECT to MySQL Server to use FORWARD/REVERSE Engineering Option 1 – Run mysql-workbench on PRClab with Display set back to your PC and use LOCAL connection – http://mercury.pr.erau.edu/~siewerts/cs317/documents/Basic-
PRClab-Account-Verification-for-CS317.pdf – Must run Xming and must set X11 Display – Launch mysql-workbench on PRClab (/usr/bin/mysql-workbench)
Option 2 – Run mysql-workbench on your PC with SSH Tunnel to PRClab MySQL Server Sam Siewert 3
Option-1 Setup Run mysql-workbench on PRClab with Display set back to your PC Enter Localhost connection for your MySQL account
Sam Siewert 4
Option-1 Example
Sam Siewert 5
Start mysql-workbench On PRClab Displayed back to PC
MySQL PRClab Password
Option-2 Setup Generate SSH Keys on PRClab for your account – In directory .ssh Copy and paste id_rsa contents into file on your
PC
– Start up mysql-workbench on your PC and set up SSH Tunnel using id_rsa private key on your PC
Sam Siewert 6
Truncated for security purposes
SSH Tunnel Configuration
Sam Siewert 7
SSH Tunnel
PRClab Account
PRClab id_rsa
PRClab MySQL username
Option-2 Example Enter PRClab Password Enter MySQL PRClab Server Password Now workbench is connected to PRClab MySQL Server over Tunnel
Sam Siewert 8
USING MYSQL-WORBENCH Example Forward and Reverse Engineering
Sam Siewert 9
A few Tips – for FORWARD Use both FORWARD and REVERSE Engineer For FORWARD, make MWB Design file Name Same as your DBMS Target – E.g. siewertsDHV1 – Make sure you
have been Granted Privileges for this DBMS to DROP, and for all DDL Commands
Rename if needed as shown
Sam Siewert 10
Right Click Here – Change all Names and Save as Filename that MATCHES
Going from Paper Design to Schemas Relational Models, ER, and EER on Paper are Helpful, but How Do We Transition to a Schema we Can Test? Workbench can be Downloaded and Installed on Windows, Max OS-X, Linux - http://dev.mysql.com/downloads/workbench Enter Design as an EER using Graphical Workbench
Sam Siewert 11
Generate SQL DDL Schema When Ready…
Reverse Engineer Existing Schema to EER DreamHome v. 1.0 – 6 Tables, Related by Foreign Keys Not Taking Advantage of EER, but Can Update Model and Export, Re-Import Data to Improve
Sam Siewert 12
Sakila EER Model
Sam Siewert 13
Tables, Views, SQL/PSM Routines, Triggers in EER
Sakila Example Tables, Views, PSM Routines, Triggers Models Relations Between Entities [Tables] and Includes Operations [Routines] More Sophisticated Design and Schema that Matches
Sam Siewert 14
Reverse Engineer Differences The Forward/Reverse Engineering is Not Perfect, but Not Bad SQL Generation from Pictures, Picture Generation from SQL Much like at GUI Code Generator Issue is Sync Between Design and SQL Sam Siewert 15
Recall DreamHome v. 2.0 ER Design Entities, Attributes, Keys, 1:1, 1:*, *:1 Relations – P. 359 Features PK and FK Attributes
Sam Siewert 16
Improvements to DreamHome v. 1.0 Connections 1:n Made Via PKs Note InnoDB Physical Engine Required for FKs Improve Model and Schema
Sam Siewert 17
FKs Require InnoDB, MyISAM default [Many options – MEMORY, FEDERATED, ScaleDB…]
DreamHome v. 1.0 EER See if We Can Improve PK, FK and Normalization
Sam Siewert 18
Check Schema and Add Test Data Review Schema
Sam Siewert 19
DreamHome v. 2.0 Global EER
Sam Siewert 20
Equivalent Using DH v. 1.0 Adapted
Sam Siewert 21