MySQL Workbench Tutorial (introductory version)

Source: Internet
Author: User

MySQL Workbench is the most recently released Visual Database design tool for MySQL AB. This tool is a dedicated tool for designing MySQL databases. MySQL Workbench has a lot of features and features, and this article, written by Djoni Darmawikarta, shows some of them through an example. We will establish a physical data model for an order system, where the order system can be a sales order or an order, and use Forward-engineer (forward engine) to build our model into a MySQL database.  MySQL Workbench is the most recently released Visual Database design tool for MySQL. This tool is a dedicated tool for designing MySQL databases. what you build in MySQL Workbench is called the physical data model. A physical data model is a data model for a particular RDBMS product; The model in this article will have some unique specifications for MySQL. We can use it to generate (forward-engineer) database objects, which can contain views in addition to tables and columns (fields). MySQL Workbench has a lot of features and features, and this article, written by Djoni Darmawikarta, shows some of them through an example. We will establish a physical data model for an order system, where the order system can be a sales order or an order, and use Forward-engineer (forward engine) to build our model into a MySQL database. The physical model created in our example using MySQL Workbench looks like this:  Create an order schemalet's start by creating a scenario that holds the physical model of the order. Click the + button (where the Red label is)  Change the default name for the new scenario for the order. Note that when you type the scheme name, the label name on the physical schemata changes as well-this is a good feature.  The order scheme is added to the catalog (the red circled part of the figure).   close the schema window after renaming the scheme.   Create order FormWe now 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 for the ORDER scheme, so that the table we created will be included in this scenario.  The table we are going to create is shown as a EER chart (EER = enhanced Entity relationship). So, double-click the Add Diagram button.   Click the table icon, and then move the mouse to the EER Diagram area and click the mouse where you want to place the first table.    for the other two tables, repeat the above action. You can move the position of the table by dragging and dragging.   Next, we will do some operations on Table1, which are done through the Workbench table editor. To open the table editor, simply right-select table1 and select the Edit Table menu.   Type the table name for Table1 ORDER.   Next, Add columns (fields). Select the Columns label. Change the column name (field name) Idorder to Order_no.  in the drop-down list box, select data type INT.   we want the value of the Order_no column to be automatically controlled by the MySQL database, so we select the AI column (auto increment--self-increment). AI is a feature of MySQL database.   You can also specify other physical properties of the table, such as its Collation property, and of course you can specify other advanced options for the table, such as Trigger and portioning (respectively, corresponding to trigger and partioning tags).   Note that at this point, in diagram, our table table1 has changed to order, and it has a column (field) order_no. In the table of contents, you can also see that there are three of tables.  black Dots to the right of the table, indicating that they are contained 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.   go back to Table Designer and add two more columns (fields): Order_date and Order_type. Order_type can have two values: S represents a sales order, and P represents a purchase order. Because sales orders are more commonly used, we specify that the default value for columns (fields) is S.  You can add the next field by double-clicking the mouse in the white area below the last column.   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 a relationshipwe have created three of tables. It's not over here, we still need to create their relationship.  Sales_order is the child table of ORDER, meaning they are 1:1, Sales_order is a child table, order is the parent table, and the order key is moved to Sales_order. So, select (click) the 1:1 Identifying Relationship icon, click on the Sales_order table, and then click on the ORDER table.   Note that when you click a table, the icon changes to a hand with a 1:1 relationship.   1:1 This is how the relationship is set; The Order_no primary key is moved to the Sales_order table and is used as its primary key.   Next, create the Purchase_order to ORDER relationship, which is still a 1:1 relationship.   We have now completed the design of the relationship between tables and tables; Save our model as ORDER.MWB.   generating DDL and databasesFinally, the purpose of designing the data model in this paper is to build a MySQL database. We will first generate the DDL (SQL CREATE script) and then execute the script.  from File | From the Export menu, select Forward Engineer SQL CREATE Script.    Finally, execute the saved SQL CREATE script. The MySQL Workbench itself does not have the ability to execute this script, and we can execute it in the MySQL command console.    You can also check to see if the table has been created.   SummaryThis article shows you how to visually build a MySQL physical data model in MySQL Workbench and use it to create a MySQL database. reprinted from: Http://blog.sina.com.cn/s/blog_5eacdffa0100ipvr.html

MySQL Workbench Tutorial (introductory version)

Related Article

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.