Você está na página 1de 24

ORACLE DATA MODELER

Getting Started
Modeling for a Small Database

February 2014

1. Introduction
In this tutorial, you will use Data Modeler to create models for a simplified library database,
which will include entities for books, patrons (people who have library cards), authors (people
who wrote the books), categories (books themes), stocks (amount of books available) and
transactions (checking a book out, returning a book, and so on).
If the instructions do not mention a particular dialog box, tab, or field, then do not specify
anything for it. This simplified tutorial uses only a subset of the possible steps for the TopDown Modeling approach (Top-down modeling gathers information about business
requirements and the internal environment, and proceeds to define processes, a logical model
of the data, one or more relational models, and one or more physical models for each
relational model. The steps and information requirements can range from simple to elaborate,
depending on your needs).
The model is deliberately oversimplified and would not be adequate for any actual public or
organizational library. For more advanced tutorials, modeling approaches, other materials and
information, see the Oracle Data Modeler documentation available online at:
http://docs.oracle.com/cd/E29463_01/index.htm
You will perform the following major steps in this tutorial:
Reverse Engineering
Develop the Logical Model
Develop the Relational Model
Generate DDL
Save the Design
Importing and Exporting
Reporting
Design Rules and Transformation Scripts

2. Reverse Engineering
Reverse engineering in Oracle Data Modeler is the ability to create models or subsets of
models from tables in a database or from an SQL script, for example, importing these
structures into the Data Modeler design instead of creating them manually.
Before starting the development of the logical and relational models presented in this tutorial,
such as the remaining functionalities explained in the document, we will follow a simple
example of reverse engineering, creating tables in an Oracle Data Modeler relational model
from a DDL file (an SQL script file).
The manual process of creating the logical model will be explained in the next section,
Develop the Logical Model. Here we will use the create_additional_library_objects.sql file
present in the Class 2 - Files folder on your Desktop.
Do reverse engineering to import the Authors, Categories and Stocks tables as follows:
1. Open the Oracle Data Modeler by clicking on the icon present on your Desktop.
2. Click Tools, then Preferences. Expand the Data Modeler node and select the DDL node.
Ensure that the option Create Domains During Import is not selected (this option
should be unchecked in order to avoid the automatic creation of domains while
importing types into the new model. In this case we want types to be interpreted as
logical types, not new domains). Click OK.
3. On the Browser panel, right click the Relational Models node and select the New
Relational Model option.
4. Click File, then Import, then DDL File.
5. In the Select DDL Files dialog box, click the plus sign and navigate to the Class 2 Files directory on your Desktop. Select the create_additional_library_objects.sql file
and ensure that in the Import To section you have the Relational_1 model selected
(the one you created in step 3).
6. Leave the remaining options as default and click the OK button.
7. In the Database Sites dialog box select SQL Server 2008 and click OK.
8. A log dialog box will appear presenting some information about the importing
operation. Check if there are any problems with the import process. If none, click
Close.
9. In the Compare Models dialog box you can compare what is going to be imported with
what you have on your model already, as well as select what you want to import in the
left panel. Expand the Tables node on the left panel to see what tables you are going
to import (optionally you can explore other tree levels). Since our model is empty we
are going to accept the defaults and click Merge.

10. As you can see, three tables were imported into your relational model (Authors,
Categories and Stocks). Later these tables will be related to other tables both in the
logical and relational models.
11. Now for some more reverse engineering click on the Engineer to Logical Model icon
present on the toolbar or expand the Relational Models node, right click the relational
model (Relational_1) and choose the Engineer to Logical Model option.
12. Accept the defaults and click Engineer. This will add the three tables to your logical
model without any relationship between them.
13. Go to section 3, Develop the Logical Model, and continue to develop your logical and
relational models.
In this section we learned how to do reverse engineering by importing an SQL script to create
three tables in the relational model and then transfer those tables to the logical model. Its
called reverse engineering because we are starting from the physical definition of the model or
its components, in order to create the relational and logical definitions. In the next section we
will do the opposite process and build the rest of our model starting from the logical model
forward.

3. Develop the Logical Model


The logical model for the database includes six entities: Books (describes each book in the
library), Authors (describes the author of each book), Categories (describes the category of
each book), Patrons (describes each person who has a library card), Stocks (describes the
amount of books available in the library, and Transactions (describes each transaction
involving a patron and a book). Three of these entities were create in section 2, Reverse
Engineering and in this section you will create the remaining entities, as well as the
relationship between them. However, before you create the entities, create some domains
that will make the entity creation (and later DDL generation) more meaningful and specific.
To start developing the logical model, go to Section 3.1, Adding Domains.

3.1 Adding Domains


In planning for your data needs, you have determined that several kinds of fields will occur in
multiple kinds of records, and many fields can share a definition. For example, you have
decided that:
The first and last names of persons can be up to 25 characters each (this is valid also
for the authors entity).
Street address lines can be up to 40 characters.
City names can be up to 25 characters.
State codes (United States) are 2-character standard abbreviations.
Zip codes (United States postal codes) can be up to 10 characters (nnnnn-nnnn).
Book identifiers can be up to 20 characters.
Other identifiers are numeric, with up to 7 digits (no decimal places).
Titles (books, articles, and so on) can be up to 50 characters.
You therefore decide to add appropriate domains, so that you can later use them to specify
data types for attributes when you create the entities (these added domains will also be
available after you exit Data Modeler and restart it later).
1. Click Tools, then Domains Administration.
2. In the Domains Administration dialog box, add domains with the following definitions.
Click Add to start each definition, and click Apply after each definition.
Name
Person Name
Address Line
City
State
Zip
Book Id

Logical Type
VARCHAR
VARCHAR
VARCHAR
VARCHAR
VARCHAR
VARCHAR

Other Information
Size: 25
Size: 40
Size: 25
Size: 2
Size: 10
Size: 20
5

Numeric Id
Title

NUMERIC
VARCHAR

Precision: 7, Scale: 0
Size: 50

3. When you have finished defining these domains, click Save. This creates a file named
defaultdomains.xml in the datamodeler\types directory under the location where
Data Modeler was installed.
4. Optionally, copy the defaultdomains.xml file to a new location (not under the Data
Modeler installation directory), and give it an appropriate name, such as
library_domains.xml. You can then import domains from that file when you create
other designs.
5. Click Close to close the dialog box.
6. Go to Section 3.2, Creating the Books Entity.

3.2 Creating the Books Entity


The Books entity describes each book in the library. Create the Books entity as follows:
1. If the logical model is not opened, in the Browser area (left side), right click the Logical
Model and chose the Show option.
2. Click the New Entity icon on the Toolbar.
3. In the Logical pane (center) press, click, diagonally drag and release the mouse button
to draw an entity box. The Entity Properties dialog box is displayed.
4. Click General on the left, and specify the Entitys name as Books.
5. Click Attributes on the left and use the Add (+) icon to add the following attributes,
one at a time. Click Apply after each attribute creation (for Data types, select from the
Domain types except for Rating, which is a Logical type).
Name
book_id

Data Type
Domain: Book Id

title
rating

Domain: Title
Logical type: NUMERIC
(Precision=2, Scale= 0)

Other Information
Primary UID (unique identifier). The Dewey code or
other book identifier.)
M (mandatory, that is, must not be null).
Librarian's personal rating of the book, from 1 (poor) to
10 (great).

6. Click OK to finish creating the Books entity.


7. Go to Section 3.3, Creating the Patrons Entity.

3.3 Creating the Patrons Entity


The Patrons entity describes each library patron (that is, each person who has a library card
and is thus able to borrow books). Create the Patrons entity as follows:
1. Click the New Entity icon on the Toolbar.
2. In the Logical pane (center) press, click, diagonally drag and release the mouse button
to draw an entity box (as a suggestion, draw the box to the right of the Books box). The
Entity Properties dialog box is displayed.
3. Click General on the left, and specify the Entitys name as Patrons.
4. Click Attributes on the left and use the Add (+) icon to add the following attributes,
one at a time. Click Apply after each attribute creation (for Data types, select from the
Domain types).
Name
patron_id

Data Type
Domain: Numeric Id

last_name

Domain: Person Name

first_name
street_address
city
state
zip

Domain: Person Name


Domain: Address Line
Domain: City
Domain: State
Domain: Zip

Other Information
Primary UID (unique identifier). Unique patron ID
number, also called the library card number.
M (mandatory, that is, must not be null). 25
characters maximum.
Patrons first name.
Patrons street address.
City or town where the patron lives.
2-letter code for the state where the patron lives.
Postal code where patron lives.

5. Click OK to finish creating the Patrons entity.


6. Go to Section 3.4, Creating the Transactions Entity.

3.4 Creating the Transactions Entity


The Transactions entity describes each transaction that involves a patron and a book, such as
someone checking out or returning a book. Each record is a single transaction, regardless of
how many books the patron brings to the library desk. For example, a patron returning two
books and checking out three books causes five transactions to be recorded (two returns and
three checkouts). Create the Transactions entity as follows:
1. Click the New Entity icon on the Toolbar.
2. Click in the logical model pane in the main area. In the Logical pane press, click,
diagonally drag and release the mouse button to draw an entity box (as a suggestion,
draw the box bellow and centered between the Books and Patrons boxes). The Entity
Properties dialog box is displayed.
3. Click General on the left, and specify the Entitys name as Transactions.
7

4. Click Attributes on the left and use the Add (+) icon to add the following attributes,
one at a time. Click Apply after each attribute creation (for Data types, select from the
Domain types, except for transaction_date, which uses a Logical Type).
Name
transaction_id

Data Type
Domain: Numeric Id

transaction_date Logical type: Datetime


transaction_type

Domain: Numeric Id

Other Information
Primary UID (unique identifier). Unique
transaction ID number.
M (mandatory, that is, must not be null). Date
and time of the transaction.
M (mandatory, that is, must not be null).
Numeric code indicating the type of transaction,
such as 1 for checking out a book).

5. Note that you do not explicitly define the patron_id and book_id attributes because
these will be automatically added to the Transactions entity after you create relations
between the entities (see section 3.5). They will be added as foreign keys when you
generate the relational model (see section 4).
6. Click OK to finish creating the Transactions entity.
7. Go to Section 3.5, Creating Relations Between Entities.

3.5 Creating Relations Between Entities


Relations show the relationships between entities: one-to-many, many-to-one, or many-tomany. The following relationships exist between the entities:
Books and Transactions: one-to-many. Each book can be involved in multiple
sequential transactions. Each book can have zero or one active checkout transactions.
A book that is checked out cannot be checked out again until after it has been
returned.
Patrons and Transactions: one-to-many. Each patron can be involved in multiple
sequential and simultaneous transactions. Each patron can check out one or many
books in a visit to the library, and can have multiple active checkout transactions
reflecting several visits. Each patron can also return checked out books at any time.
Authors and Books: one-to-many. Each book has one author and each author can be
the writer of multiple books. Each author can write one or many books.
Categories and Books: one-to-many. Each book has one category and each category
can be assigned to multiple books.
Books and Stocks: one-to-one. Each book has its own unique stock.
Create the relationships as follows. When you are done, the logical model pane in the main
area should look like the following figure. Note that for this figure, Bachman notation is used

(in order to change the notation, click View, then Logical Diagram Notation, then Bachman
Notation).

1. In the logical model pane in the main area, arrange the entity boxes in a way that
Transactions entity can be related to the Books and Patrons entities, and the Books
entity can be related to the Authors, Categories and Stocks entities (if the pointer is
still cross-hairs, click the select icon at the top left to change the pointer to an arrow).
Suggestion: turn off auto line routing for this exercise. Right-click in the Logical pane
and ensure that Auto Route is not checked.
2. Click the New 1:N Relation icon.
3. Click first in the Books box, then in the Transactions box. Accept defaults and click OK.
A line with an arrowhead is drawn from Books to Transactions.
4. Click the New 1:N Relation icon.
5. Click first in the Patrons box, then in the Transactions box. Accept defaults and click
OK. A line with an arrowhead is drawn from Patrons to Transactions.

6. Click the New 1:N Relation icon.


7. Click first in the Authors box, then in the Books box. Accept defaults and click OK. A
line with an arrowhead is drawn from Authors to Books.
8. Click the New 1:N Relation icon.
9. Click first in the Categories box, then in the Books box. Accept defaults and click OK. A
line with an arrowhead is drawn from Categories to Books.
10. Click the New 1:1 Relation icon.
11. Click first in the Books box, then in the Stocks box. Accept defaults and click OK. A line
without arrowheads is drawn from Books to Stocks.
12. Optionally, double-click a line (or right-click a line and select Properties) and view the
Relation Properties information.
13. Go to Section 4, Develop the Relational Model.
In this section we created domains in order to use them later during our models creation as
predefinitions for columns that share characteristics inside a model or across models, and
created the Logical Model of a Library by building its entities (Books, Authors, Categories,
Patrons and Stocks), the entities attributes (the information that identifies each entity) and
the relationships between them. In the next section we will create a Relation Model based on
the Logical Model we created here.

10

4. Develop the Relational Model


The relational model for the library tutorial database consists of tables that reflect the entities
of the logical model (Books, Authors, Categories, Patrons, Stocks and Transactions) and all
attributes of each entity. In the simplified data model for this tutorial, a single relational model
reflects the entire logical model. However, for other data models you can create one or more
relational models, each reflecting all or a subset of the logical model (to have a relational
model reflect a subset of the logical model, use the filter feature in the dialog box for
engineering a relational model).
Develop the relational model as follows:
1. With the logical model selected, click the Engineer to Relational Model icon, or rightclick the logical model in the navigator, then select Engineer to Relational Model. The
Engineering dialog box is displayed.
2. Accept all defaults (do not filter), and click Engineer. This causes the Relational_1
model to be populated with tables and other objects that reflect the logical model.
3. Change the name of the relational model from Relational_1 to something more
meaningful for diagram displays, such as Library (relational). Specifically, right-click
Relational_1 in the hierarchy display, select Properties and in the General pane of the
Model Properties dialog box specify Name as Library (relational) and click OK.

11

4. Go to Section 5, Generate DDL.


In this section we transformed the entire Logical model into a new Relational model by
translating the entities to tables, as well as the relationships between them. Now we are able
to translate the Relation Model to a physical representation of our model, which we will do in
the next section of this tutorial, transforming our Relation Model into an SQL script executable
in an SQL Server database.

12

5. Generate DDL
Generate Data Definition Language (DDL) statements that you can use to create database
objects that reflect the models that you have designed. The DDL statements will implement
the physical model (type of database, such as Microsoft SQL Server) that you specify.
Develop the physical model as follows:
1. Optionally, view the physical model before you generate DDL statements (only
perform steps a and b if no Physical model exists for SQL Server 2008 database):
a. With the relational model selected and expanded right-click the Physical
Models node and select New. A dialog box is displayed for selecting the type of
database for which to create the physical model.
b. Specify the type of database (SQL Server 2008, which is similar to SQL Server
2012) and click OK. A physical model reflecting the type of database is created
under the Physical Models node.
c. Expand the Physical Models node under the Library relational model, and
expand the newly created physical model and the Tables node under it, to
view the table objects that were created.
2. Click File, then Export, then DDL File.
3. Select the database type (SQL Server 2008 is the available SQL Server version that for
the purpose of this tutorial works with SQL Server 2012) and click Generate. The DDL
Generation Options dialog box is displayed.
4. Accept all defaults, and click OK. A DDL file editor is displayed, with SQL statements to
create the tables and add constraints (although you can edit statements in this
window, do not edit any statements for this tutorial exercise).
5. Click Save to save the statements to a file (.sql extension) and give it a meaningful
name (for example, create_library_objects.sql). Save it on a new folder on your
Desktop (create a new folder called Class 2- Exercise, for instance). Later, you can
run this script in SQL Management Studio to create the objects in the desired
database. Do not execute this script since its not needed at this point of the exercise.
6. Click OK and click Close to close the DDL file editor.
7. Go to Section 6, Save the Design.
In this section we created a Physical Model based on our Relational Model and exported our
work to a DDL file which is executable in an SQL Server database. Now we are able to apply the
conceptual work performed in Oracle Data Modeler in a physical database. In the next section
we will save our design, including the different models we created in the previous steps.

13

6. Save the Design


Save the design by clicking File, then Save. Specify the location and name for the file to contain
the basic structural information (for example, Library Design). Save it on the Class 2- Exercise
directory on your Desktop. A directory or folder structure will also be created automatically to
hold the detailed information about the design (for more detailed information see the 1.3.1
Section, "Database Design", of the Oracle Data Modeler documentation referred in the
tutorial).

14

7. Importing and Exporting


To use a design that had been saved by Data Modeler, or exported or saved by another data
modeling tool, you can import it by clicking File, then Import, then the type of design to be
imported. Usually, you specify a file and then use a wizard that enables you to control what is
imported. As specified in the Section 2 of this tutorial, Reverse Engineering, you can import,
for example, DDL files into your models. The available import options are:
Cube Views Metadata and Microsoft XMLA files for multidimensional models.
ERwin files from the ERwin modeling tool.
Data Dictionaries that enables you to create a relational model and a physical model
based on an existing database implementation.
Oracle Designer Model that enables you to create a relational model and a physical
model based on an existing Oracle Designer Model.
Data Modeler design that enables you to capture the logical model and any relational
and data type models from a design previously exported from Data Modeler.
Importing a domain that enables you to change and extend the existing domain
definitions. In the Import Domains dialog box, select the domains to be imported and
deselect (clear) the domains not to be imported.
In this tutorial we will try the third option, importing the Library model from an SQL Server
2012 database (previously created with the DDL file generated in Data Modeler).
Create and import the model as follows:
1. First lets create the Library database that will be imported into Data Modeler in this
section of the tutorial. Click on the SQL Server Management Studio on your Desktop
and click Connect to connect to the SQL Server with Windows authentication.
2. In the Object Explorer panel on the left, expand the node with the server name, right
click the Databases node and select the New Database option. Enter Library in the
Database Name, accept the defaults and click OK.
3. Open the create_library_objects.sql file present in the Class 2 - Files directory on
your Desktop (the file will open in SQL Server Management Studio) and on the drop
down above the Object Explorer panel select the newly created Library database. Click
the Execute button to execute the script and under the Databases node, expand the
Library and Tables nodes to ensure the tables were created. If yes, then the database
needed for this part of the tutorial is created. Now we have to create an ODBC (Open
Database Connectivity) in the Windows operating system to connect to the SQL Server
through the Oracle Data Modeler software.
4. Go to Windows Control Panel, select Administrative Tools. Inside select Data Sources
(ODBC).

15

5. Under the User DSN tab click the Add button. Scroll down the list and select SQL Server
and click Finish. Enter SQL Server in the Name box and (local) in the Server box. Click
Next.
6. Ensure that Windows NT authentication and the option to connect to SQL Server are
selected and click Next.
7. In the next two windows accept the defaults and click Next.
8. Click the Test Data Source button and if the connection to the database succeeds, click
OK three times and return to Oracle Data Modeler.
9. Close all open models or close Data Modeler and re-open it by clicking on the icon on
your desktop.
10. Click File, then Import, then Data Dictionary.
11. On the Data Dictionary Import Wizard click Add.
12. In the New/Select Database connection dialog box, enter the following information:
a. Connection Name: SQL Server
b. Username: ssd
c. Leave the password field blank
d. On the JDBC tab
i. ODBC Alias: SQL Server
ii. Database Type: SQL Server
13. Click Test to test the connection to the database and if it succeeds click Connect.
14. Select the connection you just created and click Next.
15. Select the dbo schema bellow the Library database and accept the remaining default
options. Click Next.
16. Select all the tables to be imported. Optionally you can navigate through the other
tabs to view what type of information you may import. Do not select anything else and
click Next.
17. View the import summary and click Finish.
18. View the import log and click Close.
19. The relational model is created based on the information imported from the database.

16

14. You are now able to do reverse engineering in order to create the logical model. Click
on the Engineer to Logical Model icon present on the toolbar or right click the
relational model created in the previous steps and choose the Engineer to Logical
Model option.
15. Accept the defaults and click Engineer. This will create your logical model based on the
relational one.
You can also export designs. Exporting a design enables you to save parts of the design (logical
model, relational models but not physical models and data types model) to a file. You can
export in a variety of formats, both non-Oracle and Oracle. Thus, exporting provides flexibility
in output formats. The available export options are:
Data Modeler Design
DDL (as shown in the Section 5 of this tutorial, Generate DDL).
Cube Views Metadata
Microsoft XMLA
Oracle Analytic Workspace
CSV
Reporting Schema
In this Section we will see an example of how to export to Data Modeler Design, customizing
the models and sub views to be exported.
Export the model as follows:
1. Click File, then Close, then Close Without Save in order to close the model imported in
the previous steps without saving it. Open the Library model created in this tutorial by
clicking File, then Open and then choosing the file with .dmd extension located in the
directory where you previously saved the design in the Section 6 of this tutorial, Save
the Design (Class 2- Exercise directory on your Desktop). Select the Relational
Model while opening and click OK.
2. Click File, then Export, then To Data Modeler Design. A dialog with the export options
is displayed. Click Add to add an Export Configuration. Give it a meaningful name, like
Export Library Relational, indicating that we are only going to export the relational
model.
3. In the Models box, choose the Library (relational) one and click on the arrow pointing
to the right in order to select the relational model. You can choose one or more
models to export. For this tutorial we will only export the relational one.
4. Leave the remaining options as default and click the Export button.

17

5. Navigate to the Class 2- Exercise folder on your Desktop and save the exported
model with the following name Library Design (Relational).
6. Click Save and OK.
7. Go to Section 8, Reporting.
The exporting operation is complete. Later you can open or import the relation model
exported using the Oracle Data Modeler functionalities for that purpose.
In this section we talked about some possible import and export operations and we saw an
example of how to import components or entire models into Oracle Data Modeler and also an
example of how to export information from our models or parts of them. In the import
operation we interpreted the metadata of an already created Library SQL Server database into
a Relational Model and then engineered it into a Logical Model. In the export operation we
exported part of our project into the file system, the Relational Model. In the next section we
will be dealing with the Reporting feature available in Oracle Data Modeler.

18

8. Reporting
You can view reports on Data Modeler objects in the following ways:
Generate reports as RTF, HTML, or PDF files on your local drive. They are also opened
automatically.
Use SQL Developer to view reports based on information in the Data Modeler
reporting repository.
In this tutorial we will try the first option. For more information on how to view reports with
SQL Developer based in the Data Modeler reporting repository view the Data Modeler online
documentation referred on this tutorial.
You can save individual reports as RTF (a Microsoft Word format), HTML or PDF files, and view
each report when it is opened automatically on creation or open the files for viewing later. For
HTML, several separate files are generated. The files are stored in the location specified or
defaulted for Default Reports Directory under Data Modeler preferences.
Data Modeler ensures unique names for each file. For example, if you generate a report on all
tables and if AllTablesDetails_1.rtf already exists, AllTablesDetails_2.rtf is created (if you
generate report files from the reporting repository in the reporting schema, the file names
include _rs, for example, AllTablesDetails_1_rs.rtf).
You can generate report files using either of the following approaches:
Generate reports based on currently loaded designs (this approach does not involve
creating or using a reporting schema and reporting repository).
Generate reports based on information in the reporting repository in the reporting
schema (which are explained in the Data Modeler documentation, section "Reporting
Repository and Reporting Schema").
Create reports as follows:
1. Click Tools, then Preferences. Click the Data Modeler node. In the Reporting section,
under Default Reports Directory, specify the directory where the generated reports
will be saved. For the purpose of this tutorial create a Data Modeler Reports
directory on your Desktop and define this folder as the default location for the
generated reports. Click Ok.
2. If it is closed, open the Library model created in this tutorial by clicking File, then Open
and then choosing the file with .dmd extension located in the directory where you
previously saved the design in the Section 6 of this tutorial, Save the Design. While
opening, select the relational model option.
3. Click File, then Reports.
4. For Available Reports you can select one of the types of objects for which to report
information: Tables, Entities, Domains, Glossaries, and so on. For this tutorial select
Entities.
19

5. Select the HTML output format (PDF and RTF are also available). Give a meaningful
title and name to the report (Library Design All Entities and Library Design All Entities
Report, for example) or accept the defaults.
6. Under Templates, optionally, select a report template to use. You can use a report
template to customize the types of objects to be included in a report. To create and
manage report templates, click Manage to display the Report Templates Management
dialog box. For the purpose of this tutorial ignore this option.
7. In this tutorial we will use the Loaded Designs tab to generate a report based on one
or more currently loaded Data Modeler designs. Ensure that this tab is selected. Any
way you can optionally see the Reporting Schema tab that allows you to generate a
report based on designs in the reporting repository in the reporting schema.
8. For Available Designs in the Loaded Designs tab, select the one that is available: Library
Design.
9. For Available Models the only one available is selected by default: Logical Model (since
we are reporting on entities only).
10. For Report Configurations, you can create a configuration to limit the report to specific
subviews or specific objects of the selected Available Report type or you can leave it
blank to select all subviews and all objects of the selected Available Report type. You
can add, delete, or modify configurations by clicking Manage to display the Standard
Reports Configurations dialog box.
11. Click Generate Report. A message is displayed with the location and name of the file
for the report, indicating that it will be opened automatically.
12. Click OK and view the report on Internet Explorer. You can later open the report by
navigating to the location where it was saved.
13. Click Close on the Report Generation dialog box.
14. Go to section 9, Design Rules and Transformation Scripts.
In this section we approached some of the reporting features available in Oracle Data Modeler,
such as reporting on open designs, as well as reporting on a repository created specifically for
that purpose. As an example, we created a report, in HTML format, on all the entities of our
Logical Model. This and other reports can later be updated if any changes are made to the
models. In the next section we will talk about design rules and transformation scripts and see
examples on how to apply design rules to a model to check if it complies with modeling
standards and also how to apply some custom transformations to your models.

20

9. Design Rules and Transformation Scripts


In Oracle Data Modeler you can work with predefined rules and your own design rules, to
ensure that your models comply with a set of standards, as well as transformation scripts. In
this section you will apply a predefined design rule, review and use a custom design rule,
create a rule set and use a transformation script to apply changes throughout your model.

9.1 Using a Predefined Design Rule


1. Save and close any models that are opened in Oracle Data Modeler.
2. Click File, then Open. Navigate to the Class 2 - Files directory on your Desktop, enter
the Library Design Modified folder and open the Library Design Modified model
(Library Design Modified.dmd file). Select the relational model.
3. Click Tools, then Design Rules and then Design Rules once more.
4. Expand the Logical node and then the Entity node. Notice all the predefined design
rules for Entities.
5. Select the Logical node and click Apply Selected.
6. Notice that three messages are shown in the Results panel. Two errors and one
warning.
7. Double click the Error:
allowed error.

Stocks.amount: Attributes without a datatype are not

8. To define the data type, click unknown.


9. Select Logical Type checkbox, click unknown and define the column as numeric,
precision 7, scale 0. Click OK on the three dialog boxes to return to the design rules
interface.
10. Ensure that the Logical node is selected and click Apply Selected. Verify that one of the
errors has disappeared.
11. Click Close.

9.2 Reviewing and Applying a Custom Design Rule


1. Click Tools, then Design Rules, then Custom Rules.
2. There is one custom rule already defined for you. Review what it does. If there are no
Comments in the RDBMS specified, then a Problem type error message will be
generated. If there are no Comments for the table specified, then an Error type error
message will be generated.
21

3. You can change some options like the Object where the rule is going to be applied, the
Engine used to run the script and the Type of message to be thrown. You can also
specify which library the script is coming from. For the purpose of this tutorial leave
the default options.
4. Click Apply to see the errors that are generated.
5. Notice that there are a number of error type messages displayed. Double-click the
error for the Authors table.
6. Select the Comments attribute and enter the following text: Authors provides
information about the authors of the Books. Click OK.
7. Click Apply again and verify that one of the errors has turned to a Problem because
there are comments defined but there are no comments in the RDBMS defined.
8. Double click the problem for the Authors table.
9. Select the Comments in RDBMS attribute and enter the following text: Authors
provides information about the authors of the Books. Click OK.
10. Click Apply again and verify that the problem for the Authors table disappeared.
11. Click Close.

9.3 Adding a Rule Set


1. Click Tools, then Design Rules and then Design Rules once more.
2. Select the Rules Set tab.
3. Click the plus sign to create a new Rule Set.
4. Click Rule Set properties icon.
5. From the available list on the left select the following rules: Identify attributes
without datatype for the Logical Model attributes and Complex rule - check
comments demo for the Relational Model tables.
6. Click the arrow icon to add the rules to the Rule Set. Click OK.
7. Save the Rule Set.
8. Select the Rule Set and click Apply Selected.
9. As you can see, all the design rules in the Rule Set were evaluated and some errors
from different rules have been thrown.
22

10. Click Close.

9.4 Using a Transformation Script


1. Click Tools, then Design Rules, then Transformations.
2. The transformation scripts are listed. Because the JRuby engine is not installed, you
may receive a warning message. Click OK.
3. If you click one of the scripts, you see the JavaScript that is executed when the
transformation is applied. In the Table template example, a table can be created that is
a template. The template can be applied to all the tables in your model. Notice that
the table must be called table_template. You will apply this transformation script. Click
Close.
4. The first task you need to perform is to create a table called table_template. Open the
relational model and click the New table icon in the toolbar.
5. Click in the white space of the relational design. Enter table_template for Name (the
name is not optional, you have to enter this specific name) and click the Columns
attribute.
6. Click the plus sign twice to create two columns.
7. Click OK to create the table and the columns.
8. Now you will apply these two columns to all tables in your model. Right click on your
relational model on the left panel and select Apply Custom Transformation Scripts.
9. Select the Table template uses column name script and click on the arrow pointing
to the right.
10. Click Apply. The transformation script has been applied. Click OK, then click Close and
verify that all tables in your model have two new columns.
11. You can now make changes do the template table and apply them to your model. For
instance, double click on the template table, select the Columns attribute and name
the first column as updated_date (logical type date) and the second column as
created_by (logical type varchar(25)).
12. Click OK and confirm the changes in the table template.
13. Right-click the relational model and select Apply Custom Transformation Scripts.
14. Select the Table template uses column name script and click on the arrow pointing
to the right.

23

15. Click Apply. The transformation script has been applied. Click OK, then click Close and
verify that all tables in your model have been updated to reflect the changes made in
the table template.
In this section we talked about Design Rules and Transformation Scripts and performed some
examples on how to apply predefined and custom (user created for example) design rules,
create rules sets in order to apply more than one rule at once to the design and applied a
transformation scrip to our model based on a template table in a way that all changes made to
the template table were applied to all other tables in our Relation Model.
This ends our Oracle Data Modeler Getting Started Tutorial with an example on how to model
a simple database for a Library.

24

Você também pode gostar