#Kscope
Data Warrior LLC
http://kentgraziano.com
Data Warrior LLC
Reverse Engineering (and Re-Engineer) an
Existing Database Using Oracle SQL
Developer Data Modeler
Kent Graziano
Data Warrior LLC
#Kscope
Data Warrior LLC
http://kentgraziano.com
Agenda
Bio
Reverse Engineering
Logical Model
Forward Engineer Changes
Generate DDL
Multidimensional Model
Cool Features
Demo, demo, demo
#Kscope
Data Warrior LLC
http://kentgraziano.com
My Bio
Oracle ACE (BI/DW)
Certified Data Vault Master
Data Architecture and Data Warehouse Specialist
Co-Author of
● The Business of Data Vault Modeling (2008)
● The Data Model Resource Book (1st Edition)
● Oracle Designer: A Template for Developing an Enterprise Standards
Document
Past-President of ODTUG and Rocky Mountain Oracle User
Group
Co-Chair BIDW SIG for ODTUG
KScope12 Fitness Guru
#Kscope
Data Warrior LLC
http://kentgraziano.com
Install
Mui Easy!
Download, unzip, execute!
● http://www.oracle.com/technetwork/developer-
tools/datamodeler/overview/index.html
The best part – it is Free!
#Kscope
Data Warrior LLC
http://kentgraziano.com
Reverse Engineering
Called Import
● From Data Dictionary
● From DDL files
#Kscope
Data Warrior LLC
http://kentgraziano.com
Importing a Model (Reverse Engineering)
#Kscope
Data Warrior LLC
http://kentgraziano.com
Importing from DDL
Select Import -> DDL
Click green “+” to add a file to import
Pick text file with DDL from browser
Click OK
Specify what DB the DDL came from
Navigate the Merge wizard to select what to
import
● Press Merge button
#Kscope
Data Warrior LLC
http://kentgraziano.com
Supported Databases to Import
#Kscope
Data Warrior LLC
http://kentgraziano.com
Merging the Import
#Kscope
Data Warrior LLC
http://kentgraziano.com
Viola!
#Kscope
Data Warrior LLC
http://kentgraziano.com
Adding in FKs
Many times existing DBs have no FKs
● Use the NEW “Discover Foreign Keys”
● Or draw them in by hand
Automatically tries to generate a new migrating column in the target table
● Will only show candidate columns with exact data type and size match
● If you select an existing column, it will not save the generated column
#Kscope
Data Warrior LLC
http://kentgraziano.com
Discover FKs (New Feature)
#Kscope
Data Warrior LLC
http://kentgraziano.com
Adding in FKs
#Kscope
Data Warrior LLC
http://kentgraziano.com
Creating the Logical Model
One button push!
● Creates entities
● All upper case
● Creates Attributes
● Retains case like relational model
#Kscope
Data Warrior LLC
http://kentgraziano.com
Creating the Logical Model
#Kscope
Data Warrior LLC
http://kentgraziano.com
Creating the Logical Model
● Creates relationships
● Using Barker Notation
● Drops inherited PK columns
● Drops inherited FK column
● Using Bachman Notation or Information
Engineering
● Displays inherited attributes
● Can change notation on the fly with right mouse
menu
● Keeps layout of physical model!
#Kscope
Data Warrior LLC
http://kentgraziano.com
Logical Model - Barker
#Kscope
Data Warrior LLC
http://kentgraziano.com
Logical Model - Bachman
#Kscope
Data Warrior LLC
http://kentgraziano.com
Forward Engineering Changes
Edit the Logical
● Add relationship names
● Change or add attributes
● Add new entities
● Add new relationships
Press the ‘engineer to relational model’ button
● Check dialog for changes
● Uncheck any unwanted changes
#Kscope
Data Warrior LLC
http://kentgraziano.com
Engineer to Relational
#Kscope
Data Warrior LLC
http://kentgraziano.com
Generating New DDL
Use the new Reconcile button to sync the
database and the model
● Get Compare dialog to select what to change
Will generate alters if appropriate
● New columns
● Change in mandatory setting
Will generate a complete replacement script
that copies existing data
● Change in data type or precision
#Kscope
Data Warrior LLC
http://kentgraziano.com
Generate Sync Changes
#Kscope
Data Warrior LLC
http://kentgraziano.com
Sync DDL (Alter)
ALTER TABLE HR.COUNTRIES
MODIFY ( COUNTRY_NAME NOT NULL )
;
ALTER TABLE HR.COUNTRIES ADD
( Country_Abbreviation VARCHAR2 (4) NOT NULL )
;
ALTER TABLE HR.JOBS
MODIFY ( MIN_SALARY NOT NULL )
;
ALTER TABLE HR.REGIONS
MODIFY ( REGION_NAME NOT NULL )
;
#Kscope
Data Warrior LLC
http://kentgraziano.com
Sync DDL (Recreate)
ALTER TABLE HR.JOBS RENAME TO bcp_JOBS
;
CREATE TABLE HR.JOBS
(
JOB_ID VARCHAR2 (10 BYTE) NOT NULL ,
JOB_TITLE VARCHAR2 (35 BYTE)
CONSTRAINT JOB_TITLE_NN NOT NULL ,
MIN_SALARY NUMBER (20) NOT NULL ,
MAX_SALARY NUMBER (6)
)
;
INSERT INTO HR.JOBS
(JOB_ID , JOB_TITLE , MIN_SALARY , MAX_SALARY )
SELECT
JOB_ID , JOB_TITLE , MIN_SALARY , MAX_SALARY
FROM
bcp_JOBS
;
#Kscope
Data Warrior LLC
http://kentgraziano.com
Building a Multidimensional Model
Create from 3NF Logical
Model
● Right mouse – New MDD
● Create Dimensions,
Levels, Hierarchies, Cubes
using MDD diagramming
icons
#Kscope
Data Warrior LLC
http://kentgraziano.com
Build a Dimension (from Entity)
Create Dim container
Create Level or Levels ● Pick Entity to base Level on
● Pick Level Key and Attributes
Link 1st Level to Dimension
Link other levels together to build hierarchies
Dim levels can be from different entities
Right mouse option to Engineer to Oracle Model ● Creates Oracle Dimensions in physical model
#Kscope
Data Warrior LLC
http://kentgraziano.com
Build a Dimension
#Kscope
Data Warrior LLC
http://kentgraziano.com
Cool Multidimensional Diagram!
#Kscope
Data Warrior LLC
http://kentgraziano.com
Convert to Tables
#Kscope
Data Warrior LLC
http://kentgraziano.com
Other Cool Features
Can have
● Multiple Relational Models
● From one logical
● Multiple Physical Designs
● Different database implementations from one relational
● Multiple dimensional models
Cool visual query builder for views
Real time view query tester
And much more….
#Kscope
Data Warrior LLC
http://kentgraziano.com
Other Cool Features
Standards Enforcement
● Can define and apply design rules
● One button to check the whole model and all rules
● Rules checked when generating DDL
● Vary by RDBMS and version
● Even with errors it generates the code
#Kscope
Data Warrior LLC
http://kentgraziano.com
Design Rules
#Kscope
Data Warrior LLC
http://kentgraziano.com
The Good News
It’s FREE!
Easy to learn
● You can easily be productive in a few hours
Just read the dialog boxes to see all the
properties
Bonus: There is a also a process modeler
that does data flow diagrams!
Plus lots of other business related meta data
#Kscope
Data Warrior LLC
http://kentgraziano.com
#Kscope
Data Warrior LLC
http://kentgraziano.com
#Kscope
Data Warrior LLC
http://kentgraziano.com
Contact Information
Kent Graziano
The Oracle Data Warrior
Data Warrior LLC
Visit my blog at
http://kentgraziano.com
Top Related