MySQL Workbench usage (image and text ),

Source: Internet
Author: User

MySQL Workbench usage (image and text ),

MySQLWorkbenchIt is a visual database design tool recently released by MySQL AB. This tool is a dedicated tool for designing MySQL databases.

: Http://www.bkjia.com/database/29494.html

MySQLWorkbench has many functions and features. In this article, DjoniDarmawikartaThe written articles show some of them through an example. We will create a physical data model for an order system, where the order system can be a sales order or an order, and useForward-engineer (forward engine)Generate our model into a MySQL database.

MySQLWorkbenchIs a Visual Database Design Tool recently released by MySQL. This tool is a dedicated tool for designing MySQL databases.

The physical data model you created in MySQLWorkbench is called. A physical data model is a data model for a specific RDBMS product. The model in this article will have some unique MySQL specifications. We can use it to generate (forward-engineer) database objects. In addition to tables and columns (fields), we can also contain views.

MySQLWorkbench has many functions and features. This article, written by DjoniDarmawikarta, shows some of them through an example. We will create a physical data model for an order system, where the order system can be a sales order or an order, and useForward-engineer (forward engine)Generate our model into a MySQL database.

In our example, the physical model created using MySQL Workbench looks like this:

ORDER Schema)

First, let's create a solution to save the physical model of the order. Click the + button (marked in red)

Change the default name of the new solution to order. Note that when you type a solution name, the label name on Physical Schemata also changes-this is a good feature.

The Order Scheme is added to the Catalog (Red circled in the figure ).

Close the schema window after renaming the solution.

Create order table

Now we create three tables in the ORDER Model: The ORDER table and its two sub-tables SALES_ORDER and PURCHASE_ORDER. First, make sure that you have selected the label of the ORDER scheme, so that the table we created will be included in this scheme.

The table we want to create is displayed as an EER chart (EER = Enhanced EntityRelationship ). Therefore, double-click Add digoal.

Click the Table icon, move the mouse to the EER digoal area, and click the cursor at the position where you want to place the first Table.

For the other two tables, repeat the preceding operation. You can drag a table to move its position.

In the next step, we need to perform some operations on table 1. These operations are completed through the table editor of Workbench. To open the Table Editor, right-click table1 and select the Edit Table menu.

Enter the table name ORDER in table 1.

Next, add columns (fields ). Select the Columns label. Change the column name (field name) idORDERORDER_NO.

Select the Data Type INT in the drop-down list box.

We want the value of the ORDER_NO column to be automatically controlled by the MySQL database. Therefore, we select the AI column (AutoIncrement -- Auto increment ).

AI is a feature of MySQL databases.

You can also specify other physical attributes of a table, such as its Collation attribute. You can also specify other advanced options of the table, such as trigger and portioning (corresponding to the Trigger and Partioning labels respectively ).

Note: In digoal, Table 1 has changed to ORDER, and it has a column (field) ORDER_NO. You can also see three tables in the directory.

Black spots on the right of the table indicate that they are included in a chart.

If you expand ORDER, you can see the ORDER_NO column. Because we define it as the primary key, there is a key icon on the left side of it.

Return to the Table Designer and add the other two columns (fields): ORDER_DATE and ORDER_TYPE. ORDER_TYPE can have two values: S indicates the sales order, and P indicates the purchase order. Because sales orders are more commonly used, the default value of columns (fields) is S.

You can double-click the white area below the last column to add the next field.

Use the same method to create the SALES_ORDER table and its columns (fields ).

Finally, create the PURCHASE_ORDER table and its columns (fields ).

Create Link

We have created three tables. This is not the end; we still need to create their relationships.

SALES_ORDER is the subtable of ORDER, which means they are, SALES_ORDER is the subtable, ORDER is the parent table, and the ORDER key is moved to SALES_ORDER. Therefore, select (click) 1:1 identifyingrelationship icon, click in the SALES_ORDER table, and then click in the ORDER table.

Note: When you click a table, the icon changes to a hand shape with a relationship.

The relationship is set in this way. The ORDER_NO primary key is moved to the SALES_ORDER table and serves as its primary key.

Next, create the relationship between PURCHASE_ORDER and ORDER. The relationship is still.

We have now completed the design of the relationship between the table and the table; Save Our model as ORDER. mwb.

Generate DDL and database

The data model is designed in this article to create a MySQL database. We will first generate the DDL (SQLCREATE script) and then execute this script.

SlaveFile | ExportIn the menu, select Forward Engineer SQL CREATEScript.

Finally, execute the saved SQL CREATE script. MySQL Workbench itself does not have the ability to execute this script; we can execute it in the MySQL command console.

You can also check whether the table has been created.

Summary

This article shows you how to visually create a MySQL physical data model in MySQL Workbench and use it to create a MySQL database.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.