- Google Code

Download Report

Transcript - Google Code

4
Oracle Designer:
Creating the Database Design
CMIS 570 - Powell
Copyright  Oracle Corporation, 1999. All rights reserved.
Setting the Scene
Surely, we must be
ready to begin the
database design.
You’re right. Let’s begin.
We don’t have to do this by hand,
do we?
7-2
Copyright  Oracle Corporation, 1999. All rights reserved.
Overview
• Final checks are important!
• Data model transformation
– Entities and attributes
– Relationships
• Primary and foreign key constraints
• Benefits of automating the process
• The Database Design Transformer (DDT)
7-3
Copyright  Oracle Corporation, 1999. All rights reserved.
Final Checks!
• Check each Entity:
– Should have a set of attributes
– Should be in at least one relationship
– Should have a primary key
– Should be used by at least one function
7-4
Copyright  Oracle Corporation, 1999. All rights reserved.
Final Checks!
• Check each Attribute:
– Should have at least format, length, and
optionality specified
• Check each Relationship:
– Should be accurate in its degree and
optionality
7-5
Copyright  Oracle Corporation, 1999. All rights reserved.
Repository Reports for Final Checks
“Quality” Reports:
• Entity Completeness Checks
• Function Completeness Checks
“E/R Modeling” Reports:
• Entity Definition
• Attribute Definition
• Attributes in a Domain
7-6
Copyright  Oracle Corporation, 1999. All rights reserved.
Final Checks!
 Based on the checklist, we need to:
– Add a unique identifier to the COPY entity
Let’s call it COPY NUMBER and set it as:
Mandatory, Primary, VARCHAR2 length of 6
– Add a unique identifier to the SUPPLIER
entity
Let’s call it SUPPLIER ID and set it as:
Mandatory, Primary, VARCHAR2 length of 6
Let’s do it now . . .
7-7
Copyright  Oracle Corporation, 1999. All rights reserved.
Where We Have Come From
CUSTOMER
# ID
* LAST NAME
...
originator of
for
ORDER
# ID
* ORDER DATE
...
7-8
Copyright  Oracle Corporation, 1999. All rights reserved.
Where We Are Going
Table
CUSTOMERS
Columns
# * ID
* LAST_NAME
...
Primary key
column
Foreign key
ORDERS
# * ID
* ORDER_DATE
...
* CTR_ID
7-9
Foreign key
column
Copyright  Oracle Corporation, 1999. All rights reserved.
The Data Design Model
ERD Analysis
Model
DDT
Data Design
Model
• DDT does not generate SQL
• Data Design Model consists of table
definitions
• Table definitions are later input to the
Database Generator to create the SQL to
define the physical database
7-10
Copyright  Oracle Corporation, 1999. All rights reserved.
Transforming Entities and Attributes
Analysis Model
+ Entity
+ CUSTOMER
+ Attributes
+ LAST NAME
+ Unique Identifier
7-11
Design Model
+ Table
+ CUSTOMERS
+ Columns
+ LAST_NAME
+ Primary Key
CUSTOMER
CUSTOMERS
#
*
*
o
# *
*
*
o
ID
LAST NAME
STREET
POSTAL CODE
ID
LAST_NAME
STREET
POSTAL_CODE
Copyright  Oracle Corporation, 1999. All rights reserved.
Transforming Relationships
CUSTOMERS
CUSTOMER
# ID
...
# ID
...
originator of
Mandatory
for
ORDERS
ORDER
# ID
...
7-12
ORD_CTR_FK
Not Null
# * ID
* CTR_ID
...
Copyright  Oracle Corporation, 1999. All rights reserved.
Transforming a Foreign Key
• A foreign key column is created in the
“many” table
– Matches the primary key of the referenced table
– Foreign key column is named:
<short name of the entity>_<name of the referenced column>
• A foreign key constraint is created and
associated with the new foreign key column
– Constraint object is named:
<short name of “many” entity>_<short name of “one” entity>_FK
7-13
Copyright  Oracle Corporation, 1999. All rights reserved.
Transforming a Foreign Key
CUSTOMERS
# * ID
* LAST_NAME
...
• ID is a primary key column:
– Identifies a customer
uniquely
– Cannot be null
• CTR_ID is a foreign key column:
– Same size and type as
ORDERS
# * ID
...
CTR_ID
7-14
CUSTOMERS.ID
• ORD_CTR_FK is the foreign key
constraint
Copyright  Oracle Corporation, 1999. All rights reserved.
Benefits of an Automated Tool
• Enforces standards
– Naming conventions
– Standard results
• Saves development time
• Eliminates repetitive work
• Eliminates careless errors
• Allows for changes in analysis
7-15
Copyright  Oracle Corporation, 1999. All rights reserved.
Selecting Entities to Transform
ITEM
ORDER
*
#
• ERD
Selected entities
All entities
• Front panel
Entities
5
Tables (Mapped)
7-16
Copyright  Oracle Corporation, 1999. All rights reserved.
Using the Tool
Mode
Run options
Run options
Run the Transformer in
Default Mode
Selected entities
All entities
Customize the Database
Transformer
Customize
the Design
Database
Design Transformer
Summary of run set
Entities 5
0
Tables (Mapped)
Run
Show Run Set
Settings
Modes for entity selection
7-17
Help
Settings that
rarely change
Copyright  Oracle Corporation, 1999. All rights reserved.
How We Will Run The DDT
• Initiate from the Designer launchpad
• Select “Default Mode” and “All Entities”
• Click “Run” to initiate the DDT
• When DDT has finished processing:
– Close the “Output” window
– Select “Customize the DDT” to access the
“Table Mappings” and “Other Mappings” tabs
– Here, you can see the detailed results of the
DDT run
7-18
Copyright  Oracle Corporation, 1999. All rights reserved.
Viewing the Results
Output Window
Mappings tabs
Table Mappings Other Mappings
committing changes…
committed successfully
updating dialog…
Entity
Loading Tables from the Reposi
CUSTOMERS
ITEMS
ORDERS
PRICED_PRODUCT
PRODUCTS
CUSTOMER
ITEM
ORDER
PRICED PRODUCT
PRODUCT
----------------------------------------…………………………………...
…………………………………...
Waiting for Close to be pressed..
7-19
Copyright  Oracle Corporation, 1999. All rights reserved.
ITEMS
CUSTOMERS
ITEMS
PRICED_PRODU
ORDERS
PRICED_PRODU
PRODUCTS
Summary
• Transform the analysis data model into
a data design (i.e. table definitions)
Entity
UID
Attribute
Relationship
•
7-20
Table
Primary or unique key
Column
Foreign key column
and constraint
DDT automates the process
Copyright  Oracle Corporation, 1999. All rights reserved.
Practice 1
1. View the entity relationship model
2. Write down your expected DDT results
3. After running the DDT, examine the
result – using Design Editor . . .
7-21
Copyright  Oracle Corporation, 1999. All rights reserved.
Intro to the Design Editor Tool
1. Initiate Design Editor from the Designer
launchpad
2. Select “Server Model” (the default) and
UN-check “Use a Guide”
3. Expand “Relational Table Definitions”
4. Use the shift key to select all 3 tables
5. Drag them to the “work surface” at right
6. Maximize the work surface window to
study your model
7. Print this model out if you want to
7-22
Copyright  Oracle Corporation, 1999. All rights reserved.