Visio-based database modeling in Visual Studio. NET Enterprise Architect: Part Two

Source: Internet
Author: User
Tags definition delete key final reference versions visual studio
enterprise|visual| Data | database
Terry Halpin
Microsoft Corporation
November 2001

Summary:This article is the second in a series of articles on the Visio-based database modeling component in Microsoft Visual Studio Enterprise Architect. The first section discusses how to create a new object role modeling (ORM) source model, how to add sentence types, basic internal constraints, and examples in the fact Editor (Fact Editor), and how to drag the fact type from the Business Rules editor (Business Rules editor) to the drawing window. And how to save the model. It also explains how to map an ORM model to a logical database model by creating a Database model project, adding an ORM Source model, and then building a logical model. Finally, it describes how to generate the physical database model from the logical model by selecting the target DBMS and generating the DDL script. The second section discusses how to use descriptors to mark object types as standalone types, to object associations, and to add some other ORM constraints to the ORM Source model.

Directory

    • Brief introduction
    • Descriptor
    • Standalone object types and database property tables
    • Object Affinity (Nesting)
    • Add an external uniqueness constraint
    • Add a detach force role (OR) constraint
    • Add Value Constraint
    • Summarize
    • Reference bibliography
Brief Introduction
Microsoft®visio®for Enterprise Architects (VEA) is included in the Studio®.net Enterprise version of Visual Architect and is currently Beta 2. After the release of Beta 2, many enhancements and bug fixes have been made to the product. The final version of Vea will be a superset of Microsoft Visio Professional 2002. Similarly, the product will contain simple Object role modeling (ORM) graphics solutions in Visio Professional, and a deep ORM source model solution that can provide forward/reverse engineering to/from the physical database architecture. The Help file for this product references a simple drawing stencil as an ORM mapper, referencing a deep modeling solution as an ORM Source model. The ORM Source model can be used for cartography and engineering, and is the only ORM solution discussed in this series of articles. Help files are not usually included in the BATE version, but these files can now be downloaded from the Web.
This series of articles briefly describes how to use a Visio based database modeling solution in Visual Studio Enterprise Architect. This article focuses on descriptors, object independence, nesting, and other constraints in an ORM solution. Suppose the reader of this article is already familiar with ORM and relational database modeling. An ORM overview can be downloaded from the Web [bibliography]1 and Bibliography 2], and the way in which ORM and database modeling is handled is discussed in detail in my recently published book [Bibliography]3].
The previous article discussed how to create a simple ORM model and how to map the model to a logical database schema and then map it to the physical database schema [reference number]4]. As I pointed out in that article, all Visio stencils and templates have U.S. Units and Metric units in two different versions. In the final release, only the version that is applicable to the user's region is installed by default (U.S. or metric). If you want to install two versions at the same time, you should select a Custom installation option and indicate that you need a different version of the solution. Descriptor
Both the ORM source model and the database logical model solution can automatically describe any part of the selected model, including any examples that the user may enter. This functionality is useful when communicating the meaning of a model with an expert in a non-technical field. To illustrate this feature, open the Employee ORM Source Model sample provided with the product by selecting File | New | Browse Sample Drawings(File | New | Browse the Drawing sample), and then select Database(database) folder and Employee ORM source sample files, and click Open(See Figure 1 for the) button (open).

Figure 1: Example of open ORM Source model (click image to view large picture)
The employee page for the employee source model should now be displayed. The complete model includes three pages: Employee, Project, and Room. The name of the current display page appears in the tab below the drawing window. By default, only database properties (Database properties) and Business rules (Business Rules) windows appear below the drawing window. To open the Descriptor window, from the main menu, select Database | View | Verbalizer(Database | View | Descriptor). At this point, you should display the descriptor below the drawing window. Now, use the mouse to select a part of the model that you want to describe. In Figure 2, I chose the main external uniqueness constraint. The description is displayed in the Descriptor window.

Figure 2: Description of the primary external uniqueness constraint (click the image to see a larger picture)
To select a single model element, click the element directly. To select the model area you want to describe, hold down the left mouse button and drag the cursor along the diagonal of the area. The descriptor describes various aspects of the model in the zone (if you add a fact sample and include these examples). The Descriptor window remains open until you close it, but I usually have this window open. By selecting the relevant tabs at the bottom of the displayed window, you can choose which window to display below the mapper, such as the Database Properties window, the Business rules (Business Rules) window, or the Verbalizer (Descriptor) window. Standalone object types and database property tables
In Figure 2, the two-dollar Association Employee took Course(Employee received training) has been targeted Coursework(Training work). The scope of this discussion (UoD) allows us to know that an employee has received a given training course, but that he or she does not know the final level of training obtained. As a result, examples of training work can exist independently, regardless of whether these employees play other roles in UoD. Therefore, the training work is marked "Independent" (independent), showing the name with "!". When you specify that the object type is standalone, the tool will automatically enter this tag.
To designate an object type as stand-alone, select the object type and enter an entry in its Database property sheet. If the Database property sheet is currently being displayed, you can simply click the object type to view its properties. Alternatively, double-click the object type to display its property sheet.
In the previous article, we discussed how to use the Fact Editor (fact Editor) to specify the basic aspects of a single sentence type. You can use the Database property sheet to perform all the things you can do with Fact Editor, and you can perform more advanced tasks. One of the additional features is a check box with the ability to specify whether an object type is independent (see Figure 3). The Definition pane for this table is displayed here. The pane can be displayed by simply selecting another pane of the property sheet on the Categories list.

Figure 3: Specify the independence of the training work in the Database property sheet (click the image to view the larger picture) object Affinity (nesting)
Consider Employee took Course(Employee receiving Training) Association. To be able to record the final level (if any) of an employee's acceptance of a given training, the association is converted to training and adds the fact type coursework resulted in Grade(Training work result level). Because an association is nested in the training work object type, this object type is called a nested type. Nesting is specified using the Advanced pane of Fact Editor. If you have just entered a new fact type in Fact Editor (for example, Employee plays Sport[Employee participation campaign], and the editor remains open, you can add nesting before closing the editor. Instead, if you place the object type in the diagram that you want to target, select the fact type, and then open Fact Editor, which you can use Database | View | Fact Editor(Database | View | Fact editor). Then select the Advanced (Advanced) tab, and in the Objectify/nest fact as: field, enter the object's associated name. For example, you would Employee plays Sport(Employee participation Movement) object to play. Figure 4 shows the nested declaration associated with the training work in the model example.

Figure 4: Specifying Nesting (nesting) using the Advanced (Advanced) pane of the Fact Editor (Fact Editor) (click image to view large picture)
If the association is already in the drawing window, click the Fact Editor (Fact editor) OKThe (OK) button will display a nested outer border around the association. You can also drag nested object types from the Business Rules editor to display nested object types. The name of the object association is displayed outside the nested outer frame (see Figure 3). You can select a nested object type, and then drag its control handle (shown as a small yellow diamond) to adjust the position of the name. You can also resize the bounding box vertically by dragging its shape handle (the green small rectangle).
Currently, ORM requires that each object-based association have a generated uniqueness constraint, or a 1:1 association. Enforces this rule when performing the model error check, which is error checking for models. Select from the main menu Database | Model Error Check(Database | Model error checking, you can perform basic model error checking at any time.
When you create a nested object type, the tool automatically creates the derived predicate between this nested object type and the object types involved in its definition predicate. This provides a uniform way to browse to the rest of the schema from any object type (nested or not nested), primarily for conceptual queries. By default, derived verbs are referred to as "involves" (including) or "is involved in" (included). To rename these verbs, double-click the nested object type in the Chart window, display its Database property sheet, and then select the Nested Roles (nested role) category and rename the nested role name. add an external uniqueness constraint
The first section discusses how to use Fact Editor to add internal uniqueness and simple force role constraints to a single fact type. To declare other role-based constraints, it is a good idea to select the related predicate from the drawing window and then use the ADD Constraint(Add Constraint) dialog box, or select from the main menu Database | ADD Constraints(Database | Add constraints).
Use the Employee example to practice adding constraints. Remove the constraint from the model first (select the constraint, then click the Delete key), and then use the ADD Constraint(Add Constraint) dialog box to add it back.
Assuming that the external primary uniqueness constraint in Figure 3 has been removed, you can add it back by following these steps: Press the Shift key and select Room is in building(The rooms are located in the building) and Room has ROOMNR(room with room number) fact type, then right-click and select ADD Constraint(add constraint) option. ADD Constraintdialog box opens with the constraint type set to unique. Select the Primary box to indicate that this constraint provides the primary reference architecture for the Room (room), and then select the building (building) and ROOMNR (room number) roles (click them sequentially without pressing the Shift key). The constraint description appears at the bottom of the box (see Figure 5). If the external uniqueness constraint is not used for the primary reference, do not select the Primary (main) box.

Figure 5: Add the primary external uniqueness constraint in the Add Constraint dialog box (click the image to see a larger picture)
If you click OK(OK) button, the dialog box closes and the constraint is displayed in the drawing window. If you apply other constraints to one or more verbs, you can click Applybutton to apply the constraint to keep the dialog box open and add more constraints to those verbs. Add a Detach force role (OR) constraint
The dotted circle in Figure 3 is a separatist mandatory role (OR) constraint, indicating that each employee must have a cell phone number or room (or both). For example, a signatory may have a cell phone number but no room, while a fixed employee may own a room (possibly with a cell phone number). Assuming that this constraint has been deleted, you can add it back by following these steps: Select Employee has mobilenr(Employee has cell phone number) and Employee has Room(Employee owned room) fact type; Right-click to select the ADD Constraint option; ADD Constraint(Add Constraint) dialog box, change the constraint type to mandatory (mandatory); Click Two employee roles (see Figure 6); OK(OK) or Apply(apply) button.

Figure 6: Add the Detach force role (OR) constraint in the Add Constraint (Add Constraint) dialog box (click the image to see a larger picture)
ADD Constraintdialog box can also be used to specify subsets, exclusions, equivalence, frequency, ring, and index constraints (see part III). add Value constraint
Declare the value constraint of an object type by clicking (or double-clicking) the object type in the drawing window to display its list of properties, selecting the Value category, and then entering a range of related values and/or values. In Figure 3, the Grade (level) object type is constrained to the following possible set of letters: {' A ', ' B ', ' C ', ' F '}. Suppose you delete this constraint by entering value A (without quotes) in the Value field, click ADD(add) button, and then repeat this step for B, C, F, and add it back (see Figure 7). You can click Remove(delete) button to delete the value. To adjust the value constraint on a chart, select the object type (do not select the constraint), and then move the displayed control handle (small yellow diamond).

Figure 7: Adding a simple value constraint in the Database property sheet (click the image to see a larger picture)
By default, up to five entries are displayed in a value constraint. To change this setting, right-click the object type and select Shape | Custom Properties(Shape | custom attribute), and then change the size of the Value list in the custom property sheet (see Figure 8). This dialog box can also introduce your own newly created custom properties.

Figure 8: Controlling the maximum number of entries displayed in a value constraint by a custom property
If this number is set to less than the number of entries in the constraint, an ellipsis "..." is appended to the display list, indicating that the list also contains other values, but is not displayed. This feature is useful when the list is very large. Regardless of how many values are displayed in the chart, all values that you enter in the constraint are contained in the constraint used to generate the DDL. Summary
Enough information is now available to recreate the employee page for the employee ORM source model. As a challenge, you may want to know if you can regenerate other parts of the Employee model, as shown in Project and Room pages. The third part will discuss the above operation in detail. If you have any constructive feedback on this article, please send me an email (TerryHa@microsoft.com). Reference Bibliography
    1. Halpin, T. A. Object role Modeling:an Overview (English), msdn,2001 (also access to www.orm.net,1998).
    2. Halpin, t.a. "Object Role Modeling (Orm/niam)", Handbook on Architectures of Information Systems, chapter fourth, P. Bernus, K. mertins and G. Schmidt (heidelberg:springer-verlag,1998), you can also visit Www.orm.net (English).
    3. Halpin, T.a. " Information Modeling and Relational Databases (San Francisco:morgan Kaufmann publishers,2001) can also access http://www.mkp.com /books_catalog/catalog.asp? Isbn=1-55860-672-6 (English).
    4. Halpin, T.a. Visio-based database modeling in Visual Studio. NET Enterprise Architect: The first part, msdn,2001.

(This article was originally published in Inconcept, Inc., the Journal of conceptual modeling.) )

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.