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

Chapter 18: Rose Data Modeler

Type the name of the new diagram.

4.

Double−click the diagram to open it.

As with other diagrams in Rose, the Data Model diagram has a specialized toolbar that you can use to add tables, relationships, and other data−modeling elements. Table 18.2 lists the buttons available on this toolbar.

Table 18.2: Icons in the Data Model Diagram Toolbar

Icon

Button

Purpose

 

Selects or Deselects an Item

Returns the cursor to an arrow to select an item.

 

 

 

 

Text Box

Adds a text box to the diagram.

 

 

 

 

Note

Adds a note to the diagram.

 

 

 

 

Anchor Note to Item

Connects a note to an item in the diagram.

 

 

 

 

Table

Adds a new table to the diagram.

 

 

 

 

Non−identifying Relationship

Draws a non−identifying relationship between two tables.

 

 

 

 

Identifying Relationship

Draws an identifying relationship between two tables.

 

 

 

 

View

Adds a new view to the diagram.

 

 

 

 

Dependency

Draws a dependency between two tables.

 

 

 

Creating Domain Packages and Domains

A domain can be used to enforce business rules such as required fields, valid values for the fields, and default values for the fields. A domain is a pattern that, once established, can be applied to one or more fields in the database. For example, assume you are working with a system that stores many types of phone numbers. You can set up a domain called Phone that would include all of the business rules that apply to all types of phone numbers. In the details of the domain, you can set the data type to Long, set the default value to 0, and indicate that a value is required. Once the domain is set up, you can apply it to various fields in the database: HomePhone, WorkPhone, FaxNumber, and so on. Each of these fields will now have a data type of Long, a default value of 0, and will be required.

Using domains is entirely optional, but two of the benefits of using domains are consistency and maintenance. Applying domains helps you ensure that the business rules are consistent across many fields—in this case, across all fields related to phone numbers. Domains also centralize the business rules, which can make them easier to change. If, for example, the business rules change and phone numbers are no longer required, you could change the domain and re−create the tables, rather going into each table individually and making the change.

In Rose, domains are located inside a domain package. Each domain package is assigned to a specific DBMS, and all of the domains within it must use the data types provided by that DBMS. If you are working with more than one DBMS in a given project, create separate domain packages for each. A domain is not, however, specific to a schema; a single domain can be used across multiple schemas.

To create a domain package:

1.

623

Chapter 18: Rose Data Modeler

Right−click the Logical View in the browser.

2.

Select Data Modeler → New → Domain Package.

3.

Right−click the new package and select Open Specification.

4.

Select the DBMS to use for that domain package.

Note Once you have set a DBMS for a domain package, it cannot be changed.

To create a domain:

1.

Right−click the domain package in the browser.

2.

Select Data Modeler → New → Domain.

3.

Right−click the new domain and select Open Specification.

4.

On the General tab, enter the name of the domain.

624

Chapter 18: Rose Data Modeler

5.

Select Generate on Server to generate a server−based or distinct data type.

6.

Select the domain's data type. The choices available in this list box will depend upon the DBMS of the domain package.

7.

Enter the field length for the domain. Not all data types require a field length.

8.

Enter the precision and scale for the domain. Precision is the number of digits allowed in a numeric field. Scale is the number of digits to the right of the decimal point in the number. Not all data types require a precision or scale.

9.

Select Unique Constraint if fields that use the domain must have a unique value. A constraint will be generated in the database if this field is checked. Note that not all data types will allow a unique constraint.

10.

Select Not Null if fields that use this domain must contain a value.

11.

Select For Bit Data (DB2 only) if the domain should support ForBitData.

12.

625