Documentation Home
MySQL Workbench Manual
Related Documentation Download this Manual
PDF (US Ltr) - 17.0Mb
PDF (A4) - 17.0Mb


9.3.3.1 Adding an EER Diagram

To create an EER diagram for the sakila database, first add an EER diagram by double-clicking the Add Diagram icon in the EER Diagrams panel to create and open a new EER Diagram editor.

The EER Diagram canvas is where object modeling takes place. To add a table to the canvas, select the Catalog tab in the middle panel on the right side of the application to display any schemas that appear in the MySQL Model tab. Find the sakila schema and expand the view of its objects by clicking + to the left of the schema name. Expand the tables list in the same way.

You can add tables to the EER canvas by dragging them from the Catalog panel dropping them onto the canvas. Drop the address table and the city table onto the canvas, as the following figure shows.

Figure 9.30 Adding Tables to the Canvas

Content is described in the surrounding text.

MySQL Workbench automatically discovers that address.city_id has been defined as a foreign key referencing the city.city_id field. Drop the country table onto the canvas and immediately you should see the relationship between the country table and the city table. (To view all the relationships in the sakila database, see Figure 9.35, “The sakila Database EER Diagram”.)

Click the Properties tab of the panel on the lower left and then click one of the tables on the canvas. This action displays the properties of the table in the Properties window, as the next figure shows. While a table is selected, you can use the Properties window to change a table's properties. For example, entering #FF0000 for the color value will change the color accent to red.

Figure 9.31 Viewing The Properties

Content is described in the surrounding text.

Changing the color of a table is a good way to identify a table quickly—something that becomes more important as the number of tables increases. Changing the color of a table is also an easy way to identify a table in the Model Navigator panel. This panel, the uppermost panel on the left side of the page, gives a bird's eye view of the entire EER canvas.

Save your changes to a MySQL Workbench model file (.mwb extension) by choosing Save from the File menu or by using the keyboard command Control + S.