CS317 File and Database Systems
Using MySQL Workbench [PRClab] http://dev.mysql.com/downloads/workbench
November 4, 2018 Sam Siewert Please Use Workbench 6.3.x You can install Workbench 6.3.x on your P: drive from O: drive (or T:\CS317) and run on an Campus wired machine The file ‘mysql-workbench6_Pdrive.zip’ can stay in the O:\ drive or it can move to the T:\ drive in a class folder you control. Your call.
I included instructions inside the .zip file, screenshot:
RS
Sam Siewert 2 Please use Workbench 6.3.x
You can download 6.3.x from Canvas and install on your own equipment and use Student VPN connection
Sam Siewert 3 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 - Welcome to MySQL Workbench
Sam Siewert 4 Methods to Connect to MySQL MySQL-Workbench must CONNECT to MySQL Server to use FORWARD/REVERSE Engineering Option 1 – Run mysql-workbench on PRClab1 with Display set back to your PC and use LOCAL connection – Basic-PRClab-Account-Verification-for-CS317.pdf – Or use MobaXterm for remote display and shell access to PRClab1 – Launch mysql-workbench on PRClab (/usr/bin/mysql-workbench)
Option 2 – Run mysql-workbench on your PC on Campus EagleNet, with student VPN, or with SSH Tunnel to PRClab1 MySQL Server (complicated) Option 3 - Go to STEM Room 110 or Building 16 24 hour lab and start workbench from “Start” button - 8.0 CE Sam Siewert 5 Option-1 Setup Run mysql-workbench on PRClab with Display set back to your PC Enter prclab1.erau.edu on port 3306 (default port) connection for your account (ERAU username and password)
Sam Siewert 6 Option-1 Example Start workbench On PRClab1
Displayed back to PC
Enter your MySQL user and password
Sam Siewert 7 Option-2 EagleNet or VPN Example There is no difference from Option-1 on EagleNet or VPN other than starting workbench locally on your PC! Start workbench On your PC
Enter your MySQL user and password
Sam Siewert 8 Option-2 SSH Tunnel Setup
Generate SSH Keys on PRClab1 for your account – In directory .ssh Copy and paste id_rsa contents into file on your PC
Truncated for security purposes
– Start up mysql-workbench on your PC and set up SSH Tunnel using id_rsa private key on your PC
Sam Siewert 9 SSH Tunnel Configuration SSH Tunnel
PRClab1 prclab1.erau.edu Account
PRClab1
prclab1.erau.edu id_rsa
PRClab1 MySQL username
Sam Siewert 10 Option-2 Example
Enter PRClab Password
Enter MySQL PRClab Server Password
Now workbench is connected to PRClab MySQL Server over Tunnel
Sam Siewert 11 Option-3 Example In STEM Room 110 or Building 16 24 hour lab, use Windows “Start” button to find workbench Configure a connection as before and run from PC
Start workbench On Lab PC
Enter your MySQL user and password
Sam Siewert 12 Example Forward and Reverse Engineering USING MYSQL-WORBENCH
Sam Siewert 13 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 Right Click Here – Change all Names and Save as Filename that MATCHES Sam Siewert 14 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/d ownloads/workbench
Enter Design as an EER using Graphical Workbench
Generate SQL DDL Schema When Ready…
Sam Siewert 15 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 16 Sakila EER Model Tables, Views, SQL/PSM Routines, Triggers in ER Diagram
Sam Siewert 17 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 18 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 19 Recall DreamHome v. 2.0 ER Design Entities, Attributes, Keys, 1:1, 1:*, *:1 Relations – P. 359 Features PK and FK Attributes
Sam Siewert 20 Improvements to DreamHome v. 1.0
Connections 1:n Made Via PKs
Note InnoDB Physical Engine Required for FKs
Improve Model and Schema
FKs Require InnoDB, MyISAM default [Many options – MEMORY, FEDERATED, ScaleDB…] Sam Siewert 21 DreamHome v. 1.0 EER See if We Can Improve PK, FK and Normalization
Sam Siewert 22 Check Schema and Add Test Data Review Schema
Sam Siewert 23 DreamHome v. 2.0 Global EER
Sam Siewert 24 Equivalent Using DH v. 1.0 Adapted
Sam Siewert 25