Use Rational Xde Data Modeler modeling and design database second part
content:
Introduction Logic Data Modeling Physical Data Modeling and DB2 UDB Integrated Reverse Engineering Synchronization Tools to this article
Data modeling using Rational XDE
September 2004
Introduction If you participate in the architecture of the data in your project or company, this article may help you. This article is prepared for database designers, administrators or developers that implement data models, whether logical and physics, or actual manufacturers' databases (especially DB2 Universal Database). If you have aware of the basics of relational databases (ordinary forms and specific entity relationships), it will be helpful to understand the content in this article. If you have aware of the unified modeling language (UML), especially class diagrams, they are used as virtual substitutes in the Rational® tool, which will also help you. This article describes the Data Modeler components of the IBM® Rational XDE tool set, and how to use the IBM DB2? UDB database management system. This article includes two parts: Part 1: Rational XDE and Data Modeling (Data Modeling) Perspective
Introduction to Rational XDE Description Rational Tools Successfully Use Unified Modeling Language (UML), and how to make UML model and designs database data. This part introduces the list of entities through a retail industry, which constitutes the core of this article. Data Model Perspective introduces you about the main features of the data modeling perspective in IBM WebSphere® Application Developer (or Eclipse), and takes you to build your first in Rational XDE A Data Modeling project. Part II: Data modeling using Rational XDE
Logic data modeling converts entity lists to wings full-length logical data model, and demonstrates how to convert the entire logical data model into (physical) data model. Physical data modeling and DB2 UDB integration show the generated data model from the logical data model, and how to change this model to include other (such as tablespace) physical implementation characteristics. This section demonstrates how to direct the engineering data model into a mode in a DB2 UDB database (Schema). Reverse engineering shows the entire process of reverse engineering. The DB2 UDB database created in the early days is a reverse engineering into a newest data model. From this data model, you can generate a logical data model. Synchronous tools show synchronous tools in management and dissemination of changes between logical models, physical models, and actual databases. Software Requirements The theme of this article is Rational's Data Modeler, which is a major part of the Rational XDE Rational Developer Tool Set. Rational XDE is integrated into other development workbench tools for IBM. In this article, it is used with IBM WebSphere Studio Application Developer, Version 5.1.1. Running Rational XDE in the free downloaded Eclipse Development Tools version 2.1 is possible. Install Rational XDE into WebSphere Studio Application Developer beyond the scope of this article, but this installation process is quite straightforward. The target database of this article is IBM DB2 UDB. You can download a DB2 universal database or a trial version of the Personal Edition Version 8.1.3. You have created a data modeling project, you can prepare to start a logical data modeling work. You will recall six entities that are currently all of the supermarket samples you already have, listing the properties collection of entities. In order to realize how the entity is associated and interpreted, you need a more exciting and rich media - that is, an entity relationship map. This is part of Data Modeler to give you a part of the logical model you designed. There are some mechanisms here. You will work with the Logical Data Model: Main map. Create six separate UML classes to represent six logical entities in the original list: 1. Select the edit window for the Logical Data Model: MAIN. 2. Note that the UML Class panel (left) of the Toolbox view will be automatically expanded. Select any one of Data Model: Main and Logical Data Model: Main - Note how the Data Modeler panel is expanded when the physical graph is selected. Make sure you have selected Logical Data Model: main. 3. Introduce the first entity. Click the Class from the UML Class panel list and click on the mouse in any position to click on the Logical Data Model: Main map. Waiting for a moment, Class1 appears in the form of a box. Rename it as Order. 4. Repeat the above steps to create other five classes (logical entities), named: Order Detail, Supplier, Product, Garment, and Food Item 5. Note that when you create a class, they appear as a new node in Logical Data Model's Model Explorer view. 6. Save the diagram (Ctrl-s). Your logical data model map should be image below: Entity prototype You already have your supermarket database logic design frame, your logic entity looks very like UML class. Your task is to generate an entity relationship.
In order to make the UML class more like entities, give them an entity prototype. Their icon will change in the Model Explorer view, so that a visual prompt tells us that the data model is different from your supermarket object model. Application Entity Prototype: 1. Select each class in turn. 2. Find the STEREOTYPE feature in the Properties view. 3. Click on this feature with a button. A Properties window is opened (see below). 4. In the list of Properties window, select Entity. 5. Click OK. In Model Explorer, note that the icon of the class you choose is how to program a straight line with a straight line from a file cabinet. You may also notice that the logic map also uses the same icon, slightly. If you prefer to target the prototype as a flat text (<< Entity >>), find the APPEARANCE toolbar: use one or more selected classes, click the Show Stereotype as ... drop-down list and select Shape Stereotype: Label. Note that in the help text: "<< Entity >> prototype is required to translate class into data model table". It is very good to assign class assignments. Some techniques: Sometimes the Appearance toolbar is difficult to find. If you can't find it, Window> Reset Perspective can usually make it visible. Sometimes the class has the appearance, but the Appearance toolbar button will go gray or not. Stay away from class to click the mouse and then reselect this problem. Your supermarket logic design is now understandable, even if there is still a little full. You add some classes and convert them into entities, but they still lack attributes. It's time to add these properties. One way to add attributes is to right-click entity in the Model Explorer view and select Add UML> Attribute from the context menu. This is not very efficient. All things you can do at this point are a name to the property (any attempt to add types for attributes will be rejected). Direct editing graph is a better way. Right-click the ORDER class in the logical data model diagram and select Add UML> Attribute. This time is named attribute, followed by a colon, then a type. This is the first attribute, the Order ID, looks like:
ORDER ID: INTEGER
As an added feature, when you press the Enter key, you will find the next property immediately on the next line.
Order Description: String
ORDER TYPE: ProductType
Order status: Orderstatus
Created by: String
Created Date: Date: Date
After you press the Enter key for the last line, press the EscapE button, it can delete the new properties that will be added. Carefully enter the properties shown above. The name of the two words, such as a space between the ORDER Description; there is no type of two words. Add attributes to the remaining entity to repeat the procedures described above to add all the required properties to the remaining five entities. For the Order Detail:
Order Detail ID: Integer
SEQUENCE: INTEGER
Quantity: Single
Price: Currency
For Supplier:
Supplier Number: Integer
Supplier Type: ProductType
Location: String
Active: BooleanAddress: string
For Product:
Product ID: INTEGER
Product Description: String
Product Type: ProductType
Units in stock: long
Units sold: long
Cost price: Currency
SELLING Price: CURRENCY
For Garment:
Size Range: String
Color: String
Fashion Season: String is Food item:
Sell by Date: Date
PERISHABLE: BOOLEAN
Your logical data model map should look very similar to the picture below: At this stage, you have entered all the information representations in the original entity list in this stage. Although the information is the same, the information in Data Modeler provides two unique advantages. The first is that you have a map that is created immediately; the second is, most of the data you enter to the figure becomes data in the structured model. You can produce a very free. In the data type, the data type used in the example is the analysis data type in the Ratioanl XDE. They have the advantages of direct conversion of data types that become DB2 (and other database management systems). RAIONAL XDE's online help contains a useful mapping table. In order to find the entire information: 1. Select Help> Help Contents from the menu of WebSphere Studio. 2. Click Rational XDE. 3. Look at the contents of the content: Modeling Data With Rational XDE> Transforming Tables, Classes and EJBS> Class to Table Transformation Data Type Mapping> Class to DB2 Table> Transformation Data Type Mapping. However, there are two data types that they are defined by the user. They are ProductType (referenced by the attributes of Order, Supplier, and Product entities), and ORDERSTATUS (referenced by the Order STATUS attribute). In your logical data model, these types are modeled into enumeration types. Now let's take a look at how Data Modele supports user-defined data types in the case of the supermarket. In the logical data model, modeling these types becomes an enumeration type. Enumeration Type Enumeration Type The mechanism for providing a collection of related text selection for a given attribute. In this example, ProductType has three possible values:
G - for Garment. F - for FOOD. B - for Garment and Food. First, let's introduce the logical data model diagram into ProductType and Orderstatus: 1. Select Enumeration from the UML class panel. 2. Click the mouse in the free area of the logical data model. 3. Rename the first enumeration type is ProductType. 4. Repeat the above steps, name the second enumeration type as OrderStatus. Adding a text expression for enumeration types to add attributes to enumeration types, you can add text expression of enumeration types. The process is very similar to adding properties. 1. In the logical data graph, right click on the graph representing the enumerated type and select Add Enumeration Litral. 2. Enter the value in the value domain of the enumerated type of text and press Enter. 3. After the last enumerated type of text is entered, press the ESCAPE button to clear the newly added row. 4. Save your work. The expression of ProductType text is: g f B
The expression of the ORDERSTATUS text is: create Approved on Hold Rejected Completed Part Delivered enumeration Type of fate in the supermarket, logic design has merged user-defined data types. The use of these data types cannot be easier: When you add the properties of the user-defined data type, you simply enter the name of the data type (even, although you have not defined the data type). The logic design is not the end of the story. Even at this stage, Data Modeler allows you to set a smoothed conversion setting to the physical model. When this happens, each enumerated type has two fate: or is represented as a separate table, or becomes a domain in a target database. If this difference is not very clear for you, don't worry - you will see them in this article. For now, you have to set the features that determine your two enumeration types correctly fate. First, click ORDERSTATUS in the logic diagram. Note that in the Properties view, there is a feature of the Enumeration Data Modeler feature part is named ISSEPARTABLE. The default value of this feature is True. This is what you want. ORDERSTATUS is associated with a supply chain workflow, it can change well. Class features of the entity: Agent key click PRODUCTTYPE and change the ISSEParateTable feature to false. ProductType is implemented as a domain. This is slightly lacking flexibility. I can imagine that there will be different types in the future, so a table may be a better choice. For this purpose, it is more appropriate to use a domain. It is necessary to convert to a physical model more preparation. Click ORDER entities and pay attention to the Class Data Modeler section of the Properties view, with a UsesurrogateKey feature. The default value of this feature is True. When you keep this value true, there is no need to identify any properties to identify your entity - in other words, the property is a primary key. Instead, the conversion process of the physical model generates an additional proxy key attribute. The concept of agency key is well understood in the cycle of the database design. Data Modeler saves time and workload by providing the default automation support for proxy keys. However, there is usually some reason to retain manual controls in gradually explaining. In most examples in the supermarket sample, you will appoint "Candidate" as the primary key. Change the value of the USESURROGATEKEY feature for ORDER FALSE. Repeat this operation to ORDER DETAIL, PRODUCT, GARMENT and FOODITEM. The value is True in the Supplier entity so that you can see an example of a proxy button later. Attribute Features: Each of the candidate key supermarket entities must have one or more primary keys to uniquely identify each row. Not only is the entire standard database design practice and good common sense, it also meets the standardized rules. The Supplier entity will have a proxy key generated for it. For other five entities, you need to appoint candidates. The most convenient way is to work with Model Explorer and Properties views.
Expand the ORDER entity in the Model Explorer view. Click the ORDER ID property, it is a candidate button. The right side of your perspective looks like a picture below. Note that two features of the Candidate Keys Data Modeler section of the Properties view: isnullable and OID. IsnULlable determines whether attributes can be processed as NULL - the default value is TRUE (it). Not particularly obvious OID features specifying attributes as a candidate button - the default is false (it can't). 1. Change the value of the ISNULLABLE value for the ORDER ID attribute to the value of false and OID. 2. Press the Control button in the Model Explorer view and click on the other five ORDER properties to select what they have. 3. Change the value of the ISNULLABLE in the Properties view (it can change all five attributes at a time). The value of the OID is false. You can say it is a forced for the other five attributes - they can't be null - but they are not a candidate. The right side of your perspective seems to be similar to the figure below: viable attribute changes in the logical data model diagram. 1. Select the logical data model map (click on the mouse anywhere in the edit window). 2. Click Diagram> Layer Selection 3. In the Select Layers of the Layer Selection window, select Data Modeler to enable the list. 4. Click OK. You should be able to see an icon with a silver key on the left side of the ORDER ID property, indicating this one candidate button. Repeat the above steps Specify the following candidate key: Order Detail: Order Detail ID
Product: Product ID
You can generate some or all attributes on any non-empty tag entities. Entity relationship: Strong Association You now have an entity with complete properties, and allocate the value of the primary key through the proxy key and the candidate button. However, the design of the supermarket database is not very complete. You have not introduced any association between the entity - the relationship between you have a responsible entity in the physical relationship map. To accomplish this, use a variety of associations from the UML Class panel in the Toolbox view. First, look at the association between ORDER and ORDER DETAIL. This is a typical parent-sub-relation: if there is no father order, there will be no existence of Order Detail. In Data Modeler, this is a strong association. Use the Composition Association association in the toolbar to represent it. 1. Select the logical data model diagram. 2. Click Composition Association on the UML CLASS panel. 3. Click on the ORDER entity in the figure. 4. Click on the Order Detail entity in the figure. An association is drawn between two entities. This is automatically selected in the Properties view using its visible features. The following adjustment characteristics: 1. Change the end1name to _Child Order Lines. 2. Change the end2name to _parent Order. 3. Change End2Multiplicity to 1. The results in the logical data graph look like the following figure: Naming of the relationship is encouraged in entity relationship modeling, although sometimes you may argue the relationship is so obvious, naming is unnecessary. Diversity confirmation:
An Order instance can exist for a Order Detail (even although you have not yet reached the physics). It can have zero and any number of Order Detail entities for a Order view. This is determined by the relationship between the aspect of the asterisk. When diversity is handled in the structured model of Data Modeler, Data Modeler has once again provided the advantage of the graphical display relationship. Entity relationship: An instance of a weakly associated a Order Detail requires an Order instance existence because there is a strong association between them. However, the ORDER and Supplier entities are well existed - each party does not necessarily require the existence of the other party (because it is weakly associated). This association is not crucial: an Order entity creation contains the supplier that suits them. This is a weak correlation. You can model it using a regular UML association. 1. Select the logical data model diagram. 2. Click on the Association from the UML Class panel in the Toolbox view. 3. Click on the ORDER entity in the figure. 4. Click on the Supplier entity in the figure. An association is drawn between two entities. Appropriate adjustment of this association. 1. Change End1MultIPlicity to 1 (a Order instance must have one and only one associated Supplier instance). 2. Change End2MultIPlicity to * (a Supplier instance can be associated with zero, one or many Order instances). 3. Optional, specify the name (end1name and end2name characteristics) at both ends of the relationship. Results should be imaged below: Add an association between ORDER DETAIL and PRODUCT, using the same steps as above. END1MULTIPLITY is still 1 and end2multiplicity is an asterisk (*) (an Order Detail instance can reference one and only reference to an instance of a product; however, the same product instance can exist in multiple Order Detail instances). Entity relationship: The two entities of the generalized role are left yet: GARMENT and FOOD ITEM. They are typical physical subtypes. Now you can see how Data Modeeler can simply model this concept. The applicable attributes for any product (whether clothes or food) are stored in the Product entity. The type specified by the property is saved in Garment or Food Item, respectively. If the parent Product instance does not exist, the instance of GARMENT or FOOD ITEM will not exist, so see a strong association should be appropriate (using the Composition association in the panel). However, Data Modeler has developed a generalization association for such care. Introduce it into your chart: 1. Select the logical data model diagram. 2. Click Generalization in the UML CLASS panel. 3. Click on the GARMENT entity in the figure. 4. Click on the Product entity in the figure. 5. Click Generalization 6 in the UML Class panel. Click on the Food Item entity in the figure. 7. Click on the Product entity in the figure.
Results should be shown below: Physical Data Modeling and DB2 UDB Integrated Establishing Data Model Database For your supermarket demand, the next task is to create a (physical) data model. Good news is that most difficult work has been completed. Data Modeler will automate the conversion process from logical data models to physical domain. There are two reasons for a physical model: 1. Allow physics implementation with logic and design 2. The package creates and maintains the definition required for the actual DB2 database. In real life, you may have to make multiple manual adjustments in the physical modeling stage. For the purposes of this article, you have to have a large extent to create a logical design to a physical design direct conversion. In this stage, your product demand may introduce multiple new tables and relationships. Because the target database is a DB2 database, it is best to start with a DB2 data model. When you create your data modeling project, you are provided two data models. You have made a lot of work on logical data models, there is no matter what you have to do on the (physical) data model. So you will delete the (physics) data model and create a DB2 data model. By the following steps can be done: 1. In the Model Explorer view, right-click on Data Model and select Close. 2. Switch to the Navigator view. 3. Right-click on Data Model in the DMTutorial project and select Delete. 4. Right-click on the DMTutorial project and select New> Model. 5. Select DB2 UDB from File Types from File Types and select DB2 Data Model from Templates. 6. Click Finish. Confirm (physical) data model diagram is opened in the editing window and select it. If you don't open, double-click Main in the Model Explorer view of DB2 Data MoDel (for example, physical data model branch). Note how the Toolbox view is visible, now it has been put into some tools: Let us create a database: still not a actual database in a DB2, but it is a representative in a data model diagram. . 1. Click Database in the Data Modeler panel in the Toolbox view. 2. Click on the mouse anywhere in the data model diagram. 3. A Database Description window is opened. Named the database ordb. If there is not yet set, set the target database to IBM DB2 8.x and click OK. 4. Now look at the default settings of Data Modeler (see also seen in the Data Modeling Preferences section of the Data Modeling Preferences ". Click on Window> Preferences to expand Rational XDE and select Database Defaults. Select:
Settings for: Set to (DM Tutorial) DB2 Data Model. Change the default database to ORDERDB (from the down menu selection), it is a database created in the previous steps. Make sure the default database goal is set to DB2 UDB 8.0. The change is 18 (which ensures that the constraint identifier of DB2 has legal length). Click OK to exit. The conversion logical data model now you have converted the logical data model to a (physical) data model. The word "convert" may make you think that the logical data model is changed in some way. In fact, it is not changed, although metadata in logical and physical data models has some associated elements being created. The physical data model is actually generated from the information in the logical data model. 1. Determine DB2 Data Model to be opened in Model Explorer. 2. Confirm that only the (physical) data model is opened in DB2 Data Model. This is how XDE determines the method of target model to be converted. 3. Right-click the Logical Data Model in Model Explorer. 4. Select Transform> Transform to Table .... 5. In the Available Packages panel, (DMTUTORIAL) DB2 DATA Model should have been selected. 6. The target database should be set to DB2 UDB 8.0, becomes gray and cannot be obtained. 7. Check if genealization is set on the default value of the Separate Table. 8. Check the prefix is blank. 9. Confirm that CREATE INDEXES for Foreign Keys is selected. The window looks as follows: 10. Click OK to save the data model. The result of converting to the table transitions to the table at this stage only appears in the Model Explorer view, as shown below. Note that this stage, the data model diagram still includes only a database. Especially if this is the use of the first contact of the XDE tool, there is no value in the model but not in the figure. In fact, you can remove graphics from the figure, but they will remain in the data model. To introduce the latest created table in the data model diagram: 1. Select the DB2 Data Model. 2. Click on each table in Model Explorer and drag the table to the surface. Layout these tables in the way you are habits. 3. Note that you will get the relationship between the table by dragging the table on the surface of the figure. 4. Do not drag the domain on the surface of the figure - ProductType: It is processed in different ways. (If you have done this, you can only remove it from the table). The data model diagram has many interesting features on the data model that is converted from the logical model, as shown in the figure below: First, the prototype of the UML class is changed: instead of the top of the box has a << Entity >> Now you have a << Table >>. This labes appropriate transfer from logic to physical models. Every attribute in the table has some text.
PK - Expressed with red - indicates that is the primary key. FK - Expressed with red - indicates that it is foreign key. P The upper surface of F then K - use in red - indicates that both the primary key is the attribute of the foreign key. N - Use black - indicating that the value of the attribute is allowed to be empty. NN - Expression with black - indicates that null value is not allowed. The primary key has appeared because you appointed the candidate bile in the logical model (note that the name of the main key domain, "Supplier_ID, very cleverly distinguished from manual naming primary key). A lot of foreign keys (or main / foreign keys) have appeared because you have established associations, and the settings of the early Data Modeler parameters can be automatically moved across the relationship. So, for example, if you look at the ORDER DETAIL table: it has an foreign key attribute of a Product ID. You have never been clearly adding such an attribute for a logical model; in contrast, it is referenced to the appropriate physical implementation of the relationship between ORDER DETAIL and PRODUCT. For DB2, the data type has changed significantly from the matching of the logical model (for example, TimeStamp replaces the logical Date). This map can be found in the documentation in the Help section of the Rational XDE. Data Modeler has specified all data types that are required to create a data model to be compatible with a database management system. Enumeration Types and General Relationships When establishing an ORDERSTATUS enumeration type in a logical data model, you indicate that the property isseparateTable is TRUE. This has become a past in the conversion. ORDERSTATUS is replaced by a separate table, an ORDER table with an Integer type key. It has an attribute called Enumeration and Description. ProductType's ISSEPARTABLE property is set to false. This is converted into a domain in a physical model - no longer in one figure, but it is visible in Model Explorer. There is still a single table attribute (SuPPlier Type in the ORDER TYPE, Product Type and Supplier in Product Type and Supplier) references ProductType as their data type. When you create a DB2 UDB database, they are implemented as a database constraint. You can recall it in the Transform to Table window, you have chosen "Separate Tables" as a way to implement a general relationship. Now you can see its results. GARMENT and FOOD ITEMS have been implemented by different tables. You can expect that if a product is described in a line in the Product table, there should be a corresponding row in the Garment table. The match is implemented because the conversion will use the Product ID as the primary key of the GARMENT table, but also as a foreign key - refers to the PRODUCT ID that matches in the Product table. The above practices are equally good for Food Item. As a start point, the conversion of String to VARCHAR (255) as the result of the conversion is possible, but it seems to have a high limit for many domains. You can adjust the TypeExpression property for the properties you want to modify. 1. In the Model Explorer view, expand the ORDER table. 2. Select the ORDER Description property. 3. Change TypeExpression to Char (50) in the Properties view. Repeat this step for any or all of the VARCHAR (255) attribute.
ProductType (domain - a user-defined data type) is still not displayed in any figure. When domain is constant, it can be used repeatedly in many physical models, which is a good concentrated maintenance idea. Find their best to DB2 Domain Model when you find their best. Create it now. 1. Select the Navigator view and right click on DMTUTORAL. 2. Select New> Model> File Type of Data> DB2 UDB> Template Of DB2 Domain. In the Model Explorer view, PRODUCTTYPE is moved from the primary data model to this new model. 1. Right-click the Model Explorer in the Model Explorer view and select the option CUT. 2. Model Mouse mouse button Click the DB2 Domain folder. 3. Select Options Paste. The final result should be like: Next, some changes are made to ProductType. 1. Right click on ProductType and select Data Modeler> Open Specification .... 2. On the General tag, DataType is changed to Char and Length is 1. 3. Make sure the Generate ON Server is not selected. 4. Use the default value for other domains. Note: Selecting the Generate ON Server option causes a CREATE DISTINCT TYPE DDL statement for ProductType when you are forwarding the DB2 database, which is implemented in a simpler way for productType's validity. 5. On the Check Constraint label, the expression productType in ('g', 'f', 'b') is changed to @ProductType in ('g', 'f', 'b'). 6. Find productType in Model Explorer. There is a pair of false constraints being attached to the results of the Transform to Table process. Delete them from the model. Bind DB2 data models and DB2 domain models to ensure that the primary physical model (DB2 Data Model) can use the ProductType field in DB2 Domain Model: 1. From the Model Explorer view, select and drag (DMTUTORAL) DB2 DATA MODEL to The surface of the DB2 Domain main map. Select and drag the DB2 Domain folder to the exterior of the outermost folder of the DM Tutorial DB2 Domain. 2. Click Dependency from the UML Class panel. 3. Click DB2 Data Model (on the map) and then click DB2 Domain (on the figure). You are pointing to the definition of the domain DB2 Data Model relies on the DB2 Domain model. The final result looks like a picture below: If you don't do this, save the DB2 Data Model and DB2 Domain model. TableSpaces in Data Modeler You have prepared a forward project to a real DB2 UDB database. However, before you do this, you will allocate table spaces for the table.
The physical location of the table space management table data is not necessary for a small database sample, but for your supermarket order system, some things may be you want to think in the product environment. need. 1. Assign a table to the OrderDB database. This is a requirement to define the tablespace. Complete this very simple: right-click on the orderdb in the data model diagram and select Data Modeler> Assign. In the Rational Xde Tab, you should see some output below: 2. In order to see the assigned evidence, expand the OrderDb node in Model Explorer. The table name is listed in the icon Indicates Realization Relational to the database: 3. Create a table space by right-clicking on the database in your figure and selects Add Data Modeler> TableSpace. Accept all the default settings in the creation window, including the name: TableSpace1. Add a second table space called TableSpace2. 4. In order to add a table to the table, right-click Food Item (in the figure or in the Model Explorer view) and select Data Modeler> Open Specification .... Select the Storage tag. o For TABLESPACE, select TableSpace1 from the drop-down list. o For the INDEX TABLESPACE, select TableSpace1 again. 5. Repeat this process for other tables, there is an exception: use tablespace2 as tablespace and index table space for the Supplier table. 6. In order to check the results of these changes in Model Explorer, expand the ORDERDB database node. You will see the middle of the tablespace appears in the ORDERDB node and its implementation relationship. The table space in DB2 UDB is not enough to establish a table space in Data Modeler. The corresponding table space must also be present in the DB2 UDB. Here is a brief guide to build them. 1. Open the DB2 Control Center. 2. Expand the hierarchy to display your target database. 3. Right click on the tablespace and select Create, just like the figure below. Create Table Space Wizard appears. 4. Specify one name in the wizard: TableSpace1. 5. Skip the fifth window of the wizard and specify a container by clicking Add, then picking a location. For example, select a location of the DB2 installation phase and the database directory, and name TABLESPACE1. The result is shown below. 6. Click Finish. 7. Repeat the above steps to create TableSpace2. Verify model ensures that all rules are in line with your target database. Data Modeler can help you finish this. Right click on DB2 Data Model in Model Explorer and select Validate. Occasionally, you will see a pair of errors in the Tasks view: Double-click every error in time, you will get an error source in Model Explorer. In one case, there is a column name representation Product Description. Right click and rename it to Product Desc. In other cases, there is a foreign key constraint identifier FK__CHILD ORDER LINES. Rename it for fk_childlines. Right click in DB2 Data Model and select Validate. There should be no longer a mistake. I am going to build the sample database of the supermarket. This is called a forward engineering in Data Modeler and is a one-step process.
First you can generate a DDL script and then use the DB2 command center to perform this script. For more convenience, connect the database directly from the Ratioanl XDE and run the DDL script. Here is a repeatable problem: When you perform a forward project, a "Green Field" destination is assumed. You won't get a script to apply changes, but a script that creates the entire database. This is very good if you are ready to delete a database before running forward projects. Otherwise, there is a synchronization method to avoid this necessity, which will be a brief introduction to the end of this article. 1. Right-click on the Data Model and select Data Modeler> Forward Engineer in the Model Explorer view. 2. Click Next in the first dialog window. 3. Check all the options in the second dialog window In addition to Fully Qualified Names and Quoted Identifiers: 4. In the third dialog window, click Next, use the Browse button to find a suitable directory and name a file to store DDL scripts. . You can post it back to later to see the actual scripting statement. 5. Select the Execute option in the dialog window. In Vailable Fields: o Check the drive settings is IBM DB2 App Driver. o Leave Location keeps the same ON a username and password for DB2 UDB. o Select a data source using the drop-down list (database). Note: For this article, default, the only visible database is an existing sample database called dwctrLDB. If you have other database ideas, you can set them visible. Under Windows, create a system-defined ODBC data source for your database. o Recommended: Press the Test Connection button. You should get a simple message saying "successful connection". All dialogs look as follows: 6. Click Next, Forward Engineering Wizard has completed its work. You should see a message in the last dialog window, "You Have SuccessFully Completed The Forward Engineering Wizard". 7. Click Finish and check the output of the Output view. Important Tips for Windows users If you are using Windows running this example, check the registry entry of the record DB2 JDBC Driver Software (DB2JAVA.ZIP) before running forward projects. You will find a reference in the XDE Help: Connecting to Database Management Systems - DB2 Database Connections. After the Rational XDE is installed, you will find a registry key: hkey_local_machine / software / jud, for this article, this value is set to: C: / Program Files / Sqllib / Java / DB2JAVA .zip This key value must be changed to the following value: c: / program files / ibm / sqllib / java / db2java.zip Suppose you successfully complete the process of positive engineering, you should have some in your physical data Tables and indexes. In the default, after you connect to the database, they are attached to a named mode.
Here is a screenshot of the DB2 Control Center, which shows the table created: If you want to view the DDL script, open them in the text editor. The following is a short example: CREATE TABLE Supplier (Supplier_ID INTEGER GENERATED ALWAYS AS IDENTITY, Supplier_Number INTEGER, Supplier_Type VARCHAR (255), Location VARCHAR (255), Active SMALLINT, Address VARCHAR (255)) IN Tablespace2 INDEX IN Tablespace2; CREATE TABLE Order_Detail (Order_Detail_Id INTEGER NOT NULL, Sequence INTEGER, Quantity REAL, Price DOUBLE, Product_Id INTEGER NOT NULL, Order_Id INTEGER NOT NULL) IN Tablespace1 INDEX IN Tablespace1; CREATE INDEX Foo_Constraint26 ON Food_Item (Product_Id) PCTFREE 0; Congratulations! You have completed your supermarket database demand to convert from logical data models to (physical) data models to the actual DB2 UDB database! You may want to use DB2 UDB's work to add some data and test some unique keys and other constraints. Obviously, you have made a lot of work in Rational XDE. Even an example of such a small number of tables, create your database than using DDL, Data Modeler input is simpler and fast. Consider your current situation, you have not only physically DB2 database, but also: You still have a logical data model and some related maps, they can be used to discuss further demand with your users. You have a physical model connected to the logical data model, and you can use them as the basis for all of your future database maintenance. Reverse Engineering Take Reverse Engineering To this, you have obtained a logical business requirement and as a database. It is likely that you have already encountered a reverse demand in your development project: you already have a database and want to do one or more things:
Visual tables and relationships Maintain Your database is to get your existing database designs back to logic models to redesign or expand it. Now we will use the sample database you just created and convert it back to the (physical) data model, and then look at this support in Rational Xde Data Modeler in Rational XDE Data Modeler. The point to pay attention is: This is not an example of the real world you can call. The sample database you created is very close to our logical model. Therefore, this is an opportunity to convert a physical database into a logical model without too many manual intervention. You will likely find that your legacy database is not very matching with the logical model. There is a phenomenon that physical data is usually very unregified (usually because of performance reasons), and your logical model wants to display this specification. Therefore, the column name needs to be rewritten. I have used the name of only 6 characters, as this is the constraint that we choose the programming language. Our logical model requires the names that can be described to enable end users to understand. Data Modeler can bring you great benefits in this case. Because it allows logical names to synchronize with very different physical names. Creating a new DB2 data model Let's take a look at the actual steps of converting the sample physical database into a data model. You will create a new model for this purpose. The new model you can create will be saved in the same XDE data modeling project. One way to create a new model is to right-click the project in the Navigator view and select New> Model .... In the New XDE MODEL window, select DB2 UDB Data Model-DB2 UDB as a template for file types and data models. Name it DB2 Data Model 2. When you click Finish in the window, you will get a newly created model of blank. Save the model and close the figure. Reverse Engineering to DB2 Data Model Now you have to convert sample database into newly created data models. 1. Right-click the model in the Model Explorer view and select Data Modeler> Reverse Engineer .... You will see the welcome dialog of the Reverse Engineering Wizard. 2. Click Next. 3. Select from the database (rather than a DDL script) to perform reverse engineering. 4. In the next dialog, accept the default settings, but provide username, password, and data sources: 5. Click Next. 6. Select the appropriate mode that matches the ORDER RETAIL sample. 7. Click Next. 8. Check all additional elements. 9. Click Next. The wizard will generate a model for you. 10. Click Finish in the final window and check the errors displayed in the Output view. By default, a new Storage Modeling Diagram is opened, showing all tablespaces in your physical database - not just TableSpace1 and TableSpace2 you are placed in the table in ORDER RETAIL. Close this picture, transfer attention to the Model Explorer view. In this view, you should find a new named package. Exhibition card, you can see the list of Order Retail samples. Will also see a main map at the level of this package - open this picture now. The figure is empty. Drag the table one by one of the table, and arrange them according to your habits. The following figure shows the final result: note how the reinforcing foreign key and primary key is converted to the association of diversity. Even if the relationship is not displayed (because proper constraints in your database), this technology can be used to display where to add constraints.
Normally - if you start, in addition to the ORDER RETAIL database - this is the best way to get some graphical documents with minimal workload. Table to class - Conversion Back to the logical model Now you have seen how simple from physical database generating data models, you only have a step to do: convert the data model into logical data model. 1. Create a new logical data model (for example, Logical Data Model 2) in the DMTutorial project. 2. A new main map in the new logical data model is turned on; keep this picture in the open state. 3. In the Model Explorer view, right click on (physical) data model packages and select Transform> Table To Class .... 4. One window opens the available target packages. This should be a list of entries, which shows your new logical data model. Accept other options and click OK. 5. Check the logical model in the Model Explorer view. There should be several new entities corresponding to the converted table. Drag new entities to logic diagrams, layout in the way you habb. This example shows the following: Through few work, you have returned to your retail database logical view. Evaluate the entire process This process includes: forwarding: (a) logical data model> (b) Data model> (c) DB2 database reverse: (c) The same DB2 Database> (D) New Data Model> (E) New The logical data model is a comparison between the logical data model in (a) and the logical data model completed by the reverse process in (e). There are some different and some things worth noting: