Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

Database/Data Model Round-Trip Engineering with MySQL

Save for later
  • 180 min read
  • 2009-10-15 00:00:00

article-image

Power*Architect—from SQL Power—is a free software data modeling tool, which you can download from its website www.sqlpower.ca and use it under GPLv3 license.

Reverse Engineering

To reverse engineer is to create the data model of an existing database.

To reverse engineer an existing database in Power*Architect, we need to connect to the database. Figure 1 shows the Power*Architect's connection window where we define (create) our connection to the MySQL sales database that we'd like to reengineer.

databasedata-model-round-trip-engineering-mysql-img-0

Figure 1: Creating a database connection

By adding the conn_packt connection, the sales database objects are now available in Power*Architect.

databasedata-model-round-trip-engineering-mysql-img-1

Figure 2: Adding a database connection

By expanding the sales database, you can see all the objects that you need to create its data model.

databasedata-model-round-trip-engineering-mysql-img-2

Figure 3: Database objects

You create the ER diagram of the sales data model by dragging the sales object into the canvas (called playpen in Power*Architect)

Note that the objects in the model (those in the diagram) are now in the PlayPen Database.

databasedata-model-round-trip-engineering-mysql-img-3

Figure 4: Database objects in the PlayPen

Now that you have created the data model, you might want to save it.

databasedata-model-round-trip-engineering-mysql-img-4

Figure 5: Saving the data model (project)

databasedata-model-round-trip-engineering-mysql-img-5

Figure 6: Saving sales.architect data model (project)

You have completed the sales database reverse-engineering.

Updating the Data Model

Let's now add two new tables (hardware and software) and relate them to the product table. You add a table by clicking the New Table tool and dropping your cursor on the white space of the canvas.

databasedata-model-round-trip-engineering-mysql-img-6

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime

Figure 7: New Table tool

Type in the name of the table, and then click OK.

databasedata-model-round-trip-engineering-mysql-img-7

Figure 8: Adding hardware table

We now add a column to the hardware table by right-clicking the table and selecting New Column.

databasedata-model-round-trip-engineering-mysql-img-8

Figure 9: New Column menu selection

Type in the name of the column (model), select VARCHAR data type (and its length), then click OK.

databasedata-model-round-trip-engineering-mysql-img-9

Figure 10: The model column

After adding the two tables and their columns, our ER diagram will look like in Figure 11.

databasedata-model-round-trip-engineering-mysql-img-10

Figure 11: The hardware and software tables

Our last update is relating the hardware and software tables to the product table.

Select the New Identifying Relationship tool; click it to the product and then the software.

databasedata-model-round-trip-engineering-mysql-img-11

Figure 12: New Identifying Relationship tool

The software table is now related to the product table. Note that the product's primary key is migrated to the software table as a primary key.

databasedata-model-round-trip-engineering-mysql-img-12

Figure 13: software and product tables are related