Flylib.com

Books Software

 
 
 

Chapter 6: Configuring, Manipulating, and Reusing ORM Models


Chapter 6: Configuring, Manipulating, and Reusing ORM Models

6.1 Configuring ORM Preferences

When you first work with the ORM modeling solution, the tool applies various default settings to determine how it displays the user interface, and how it reacts to certain user commands. You can change these settings to better suit your personal preferences by entering your choices in the Database Modeling Preferences dialog.

To access this dialog, choose Database > Options > Modeling from the main menu. The dialog includes Fact Editor and ORM Diagram panes for setting ORM preferences. The other two panes deal with preferences for the logical modeling solution, and are covered in a later chapter.

Figure 6-1 shows the Fact Editor pane of the dialog with the category set to Input preferences. Use this to choose Guided or Freeform entry, decide whether to combine "at most one" and "some" as "exactly one" in constraints, and use capitals or brackets to distinguish object types. These options were explained in sections 4.2 and 4.3.

click to expand
Figure 6-1: Configuring input preferences for the Fact Editor.

Use the Category list-box in the Fact Editor pane to select the Miscellaneous preferences and Syntax Colors options displayed in Figure 6-2. These options should be selfexplanatory. For further details on any of these options, select the option, then press the F1 key to display the context-sensitive help.

click to expand
Figure 6-2: Configuring other Fact Editor preferences.

Select the ORM Diagram tab of the Database Modeling Preferences dialog to display the ORM Diagram pane shown in Figure 6-3. By default, the option for When removing an object from a diagram is set to "Ask user what to do." This ensures that if you press the Delete key when one or more model elements are selected, you are prompted whether to delete them from the diagram only or from the model as well. This prompt can save you from an accidental deletion, so don't change this default setting unless you have good reason to do so.

click to expand
Figure 6-3: Configuring ORM diagram preferences.

The Object type name field allows you to control the base default name for new object types. By default, this is "Object." The Append ordinal check box is used to append numbers 2, 3, etc., to the default names of second and later object types. So unless you choose otherwise , new object types are named "Object," "Object2," etc., until you rename them. To view this behavior, drag the Object Type shape from the ORM stencil multiple times onto the drawing window.



6.2 Showing Relationships for Object Types

In an ORM schema, object types may be connected by predicates and/or subtype relationships. Graphically, a predicate is depicted as a named sequence of one or more role boxes, and a subtype relationship is depicted as an arrow from subtype to supertype . To understand the impact of a given object type within a model, it is extremely useful to view all of its connections to the rest of the schema.

Although you can use the Business Rules window to drag all of an object type's fact types onto the drawing window, this can be tedious since you need to search for all the fact types that include the object type at any position in the predicate (start, middle, or end). Moreover, the Business Rules window does not include the subtype connections for the object type. Fortunately, the context menu of an object type includes a Show Relationships operation that let's you display all of its connections in one go. Applying this operation to an object type displays all of the fact types and subtype relationships in which it participates.

The best way to understand this operation is to watch it in action. Let's see how it works using the Patient CS model. Open this model, and then insert a new page by selecting Insert > New Page from the main menu. If the Page Setup dialog appears, press the OK button to accept the default settings. The drawing window now displays a new, blank page. Open the Object Types pane of the Business Rules window, and drag FemalePatient onto the drawing surface. Now right-click this shape to display its context menu, and select Show Relationships , as shown in Figure 6-4.

click to expand
Figure 6-4: Right-click an object type to access its context menu.

This results in the display shown in Figure 6-5. In the global schema, FemalePatient participates in the two fact types shown and in a subtype relationship to Patient.

click to expand
Figure 6-5: The display after applying Show Relationships to FemalePatient.

Now right-click the PapSmear object type, and choose Show Relationships from its context menu. This adds to the display all the other connections for PapSmear. This results in two more fact types being displayed, as shown in Figure 6-6.

click to expand
Figure 6-6: The display on applying Show Relationships to PapSmear in Figure 6-5.

Using the Show Relationships feature, you can progressively open up a model, expanding the neighborhood displayed for any object type you choose. This is very useful for model browsing, and for deciding what the impact would be of removing an object type from the model. As we'll see in a later chapter, it is also extremely useful for displaying an ORM model that has been reverse-engineered from an existing database.