The <Gen-it> Manual

 

 

 

 

 

<Previous

6. XMI using Rational Rose Example

On this page we will give you an example of how to create a XMI file using Rational Rose.

The first thing you must do is install Rational Rose and the Unisys XMI plug-in. Both can be downloaded from the Rational website.

When you have installed Rational Rose you can create a new model for your database modeling. We recommend that you use a separate model for your database model because every class in the model will be exported to the GXF file. When you add other classes to the model these classes end up in the GFX file (you can use packages and change the XMI.xsl transformation template if you want to use both types of classes in your model).

When you want to model your database you create a 'normal' class diagram. Note that we don't use the datamodel features of Rational. Then you can create classes, attributes and associations in the diagram. Now comes the tricky part: in order to get the <Gen-it> XMI conversion to work you must do the following in your diagram:

Model primary and foreign keys as attributes (this isn't normally done in logical models, but remember that we are actually creating a physical model of the database).

  • Give primary key attributes a stereotype of "PK"
  • Give foreign key attributes a stereotype of "FK"
  • Give all other attributes a stereotype that specifies if the attribute is optional. In the example we used "NULL " and "NOT NULL".
  • Give all attributes type that exactly describes their database datatype. So don't use the build in types String, Long, etc. but use VARCHAR(2000), INTEGER and DATETIME.
  • Finally, association names must be exactly the same as the foreign key attribute that is used to implement the association. Watch the multiplicity of the associations because they will determine if the foreign key attribute will be optional or not.
  • Optionally you can set the "aggregate" attribute for one of the association ends. Rational will show this by placing a diamond at the appropriate end in the diagram. This will result in the GXF file with an element <Reference.aggragation> with a value of "shared" (otherwise the value is "none").

A final note: remember that if you want to use the all the names in your model in your database and programming language that you can't use any reserved words. In the example page you can see a class named "OrderTotal". We didn't use "Order" because this is a reserved word in SQL.

When your model is ready you can export it to XMI using the menu option 'export to XML' which can be found under the file menu.

<Previous