In my last blog post, I described how to create a database schema using MySQL Workbench.
In this post, I'll describe how you can create an actual database from the schema.
Here is an example schema I created with MySQL Workbench of a fictitious video streaming company. As you can see there are 7 tables: Users, Viewings, Videos, Tiers, Providers, Bills and Contacts. For the sake of simplicity, I'm pretending that we live in a perfect world where security issues, PCI compliance etc. are not an issue.
In MySQL Workbench, the process of creating a schema from an existing database is referred to as 'reverse engineering.'
The process of creating a database from a schema is referred to 'forward engineering.' This process if what we will be concentrating on now.
The first step is to select 'Forward-Engineering' from the database menu:
That brings up a wizard:
There are a number of different options on this screen which you may have to configure depending on how MySQL is setup on your system, and how you want to connect to it.
Ensure that your username is correct.
The second page of this wizard looks like this:
There are several options that you can change, though you can also keep the defaults.
When you click 'Next', you'll be prompted for a password.
You'll also see this page:
When you click 'Next', you'll see the SQL script.
You can copy the script to your clipboard, or save the file. You can also directly edit the script if you like.
When you click 'Next', the operation will be executed.
Here you can see the final product in phpMyAdmin: