Forward engineering the data model
You can take your data model and forward engineer it into a
product or, more likely, a test environment. The Rational XDE will either
generate the data definition language (DDL) for your model, create the data
model, or both. To generate a data model, select the database from the Model
Explorer window, right-click the mouse button, and select Data Modeler`Forward Engineer.
A wizard will help you select the objects that you want to
forward engineer, specify a file to contain the generated DDL, and specify a
database to execute the DDL, or any combination thereof. In the example below,
I chose to generate the DDL for the data model. This DDL could be checked into
Rational Clear Case or source control program from the IDE and re-used for a
test environment:
As you can see, only the DDL for my table was generated,
which is all I selected in the wizard.
Reverse engineering the data model
So far in this article, I have shown you how to create and
forward engineer a data model into a test or production environment. You can
also generate a data model from an existing database and work with it in the Rational
XDE. You can reverse engineer a data model by selecting your project from the Model
Explorer window, right-clicking the project, and selecting the Reverse
Engineer option. A wizard will help you through the process. You can
reverse engineer your data model from an existing DDL file (for example, the
one that you created using the Rational XDE, or one created using the db2look
command), or from a database, as shown below:
As you can see in the previous figure, I decided to connect
to the BANKDB database and reverse engineer only the table spaces for my
database. (As you can see, the USERSPACE1 table space contains two tables,
DEPTXDE and EMPXDE.)
At this point, you could add more objects to the data model
and synchronize the changes back into the database, or vice versa.
For
example, you can see in the previous figure that I added a view to the data
model. (To do this, follow the instructions to add a table outlined earlier in
this article, only instead of a database realization, draw a view dependency.)
The view is based on tables that exist in the table space but were not imported
as objects into the model since they are part of a different schema.