Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Mastering UML with Rational Rose 2002.pdf
Скачиваний:
142
Добавлен:
02.05.2014
Размер:
9.68 Mб
Скачать

Chapter 18: Rose Data Modeler

) ON TSP0

GO

CREATE INDEX TC_T_Customer2 ON T_Customer (ZIP_CODE)

GO

Updating an Existing Database

Once a database has been created, you may make changes to either the data model in Rose or the database itself. Frequently, the two get out of synchronization, which can cause difficulties when trying to further modify the database design or maintain the application later.

Rose includes a compare−and−synchronize feature to address this problem. The feature includes a graphical, side−by−side representation of the database and data model. Using this feature, you can select the changes to be made to the data model or database to synchronize the two again.

To begin the synchronization, right−click a schema and select Data Modeler → Compare and Sync. You will be given the option to synchronize with either a DDL script or a database. If you select DDL script, you will be prompted for the name of the script. If you select database, you will be prompted for the database connection information.

Next, select the options you would like to synchronize. Rose will always synchronize tables and constraints, but you can also synchronize indexes, triggers, and other elements.

653

Chapter 18: Rose Data Modeler

Rose will then display the differences between the model and the database, as shown in Figure 18.2. Select a difference in the table, and then select one of the following four options from the toolbar:

Import, which will import the change from the database into the data model

Export, which will export the change from the data model to the database

Delete, which will remove the change from both the data model and the database

Ignore, which will ignore the change

Figure 18.2: Model and database compare−and−synchronize feature

Once you finish the changes, select Next. Rose will allow you to preview the changes to be made. When you are satisfied with the list of changes, press Next to commit the changes.

654

Chapter 18: Rose Data Modeler

Reverse Engineering a Database

You can reverse engineer a database into a data model in Rose. When you reverse engineer the database, Rose will create the database component in the Component view and the tables and other database elements in a schema in the Logical view. Once you have reverse engineered the database, you can generate an object model or perform a synchronization using the methods described earlier in this chapter.

To begin the process, select Tools → Data Modeler → Reverse Engineer. After the welcome screen, you will be asked whether to reverse engineer from a DDL script or a database. If you select DDL, you will be prompted for the target DBMS and the name of the file. If you select database, you will be prompted for the database connection information.

Next, select the item(s) to reverse engineer. Tables and constraints will always be imported, but you can select other elements to reverse engineer.

When you have finished, click Next. Rose will create a schema in the Logical view. Within this schema will be the tables, constraints, and other model elements from your database. If Rose encounters any problems during the reverse−engineering process, these will be noted in the log. Rose will also create a new component in the Component view. This component represents the database itself.

655

Chapter 18: Rose Data Modeler

Summary

In this chapter, we examined the data−modeling capabilities of Rose. Combining the object model and data model into a single tool helps the team gain a more complete understanding of the system structure and organization. The forward− and reverse−engineering capabilities help you ensure that your object model, data model, and database stay synchronized.

In this chapter, we specifically discussed the following:

The differences between an object model and a data model

How to create a data model

How to add data−modeling elements

How to generate an object model from a data model

How to generate a data model from an object model

How to generate and reverse engineer a database

How to keep your object model, data model, and database synchronized

In the next chapter, we'll focus on web development, looking at the different stereotypes and tools Rose provides to model an Internet or intranet application. With these tools, you can model ASP, JSP, HTML pages, and other web objects. Using Class diagrams, you can see the relationships between these objects and analyze your application architecture. The Rose Web Modeler add−in is an excellent way to visualize existing applications or to design new ones.

656