Since this is a very simple example, and all we have to generate is table information, select only the Export MySQL Table Objects option and click Next to review the generated SQL script:Īssuming the script appears as expected given the initial model from which it has been generated, click Next to specify the server to which the script is to be sent (or save the script if it is to be used later, perhaps within the SQL Editor or mysql client):
In addition, the objects that are to be generated may also be selected. Unless you have specific requirements, leave the default selections unchanged. In the resulting dialog, a range of selections are available to filter and modify the script that will ultimately be generated. To achieve this, select the Database -> Forward Engineer… menu option. Having created a model, the next step is to generate a SQL script from the model and feed it through to a database server where it will be executed to create the physical database and table. Generating a Script and Creating a Database Each of these should be declared as non-null by checking the boxes in the NN column:īefore proceeding, save the model using the File -> Save Model menu item, or using the appropriate toolbar button. Repeat these steps to add a price column of type FLOAT and a quantity column of type INTEGER. Accept the default value of VARCHAR for the datatype. Select the second line, double click in the Column Name field and name the column product. For the purposes of this exercise we will keep this column, though in practice this can be changed. This is achieved by double clicking on the Add Table button in the Tables panel:Ĭhange the table name to inventory and then select the Columns tab to begin the process of adding columns to the table:īy default, the workbench will create a non-null primary key named idinventory. Having given our schema a name, we can now add a table to the model.
In the resulting properties panel change the name of the schema to mySample:Ĭlose the schema property panel by clicking on the small “x” next in the Schema tab.
A new panel will be added to the workbench labeled Model:īegin the modeling process by double clicking on the tab labeled mydb MySQL Schema. To create a new model, start the MySQL Workbench tool and click on the Create New EER Model option located in the Data Modeling column of the home screen.