36
#Kscope http://kentgraziano.com Reverse Engineering (and Re-Engineer) an Existing Database Using Oracle SQL Developer Data Modeler Kent Graziano Data Warrior LLC

Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

Embed Size (px)

DESCRIPTION

SQL Developer Data Modeler (SDDM) is a full function data modeling tool provided for FREE by Oracle. It has many features built in that can be leveraged to capture the design of an existing (probably undocumented) database, retrofit it to a logical model, re-engineer it to multiple physical models (including multi-dimensional), and even apply standards, then generate revised DDL to implement your newly standardized design. You can even use one logical model to develop multiple physical models that can be deployed to different RDBMS. The presentation will provide step-by-step instructions on how to do all this so the attendees can go back to the office and quickly create diagrams of all their existing databases (Oracle and non-Oracle!). See more content like this by following my blog http://kentgraziano.com or follow me on twitter @kentgraziano.

Citation preview

Page 1: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 2: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 3: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 4: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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!

Page 5: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Reverse Engineering

Called Import

● From Data Dictionary

● From DDL files

Page 6: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Importing a Model (Reverse Engineering)

Page 7: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 8: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Supported Databases to Import

Page 9: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Merging the Import

Page 10: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Viola!

Page 11: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 12: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Discover FKs (New Feature)

Page 13: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Adding in FKs

Page 14: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 15: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Creating the Logical Model

Page 16: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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!

Page 17: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Logical Model - Barker

Page 18: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Logical Model - Bachman

Page 19: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 20: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Engineer to Relational

Page 21: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 22: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Generate Sync Changes

Page 23: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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 )

;

Page 24: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

;

Page 25: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 26: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 27: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Build a Dimension

Page 28: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Cool Multidimensional Diagram!

Page 29: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Convert to Tables

Page 30: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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….

Page 31: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 32: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Design Rules

Page 33: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#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

Page 34: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Page 35: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Page 36: Reverse Engineering an Existing Database Using Oracle SQL Developer Data Modeler

#Kscope

Data Warrior LLC

http://kentgraziano.com

Contact Information

Kent Graziano

The Oracle Data Warrior

Data Warrior LLC

[email protected]

Visit my blog at

http://kentgraziano.com