DFo 4 1 SG
DFo 4 1 SG
DFo 4 1 SG
4-1
Oracle SQL Developer Data Modeler
2
Objectives
• This lesson covers the following objectives:
−Use Oracle SQL Developer Data Modeler to create:
• Entities, attributes, and UIDs with correct optionality and cardinality
• Supertype and subtype entities
• Arc, hierarchical, barred, and recursive relationships
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 3
Oracle SQL Developer Data Modeler
3
Introduction to Oracle SQL Developer Data Modeler
• Oracle SQL Developer Data Modeler offers a range of
data and database modeling capabilities, enabling you
to:
−Capture business rules and information
−Create process, logical, relational, and physical models
−Store metadata information in XML files
−Synchronize the relational model
with the data dictionary
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 4
Oracle SQL Developer Data Modeler
4
Oracle SQL Developer Data Modeler Interface:
Example Overview
Main
Menu
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 5
Oracle SQL Developer Data Modeler
Main Menu
The Main Menu contains some standard entries, in addition to entries for features that are specific to the
Data Modeler. Icons under the menus perform actions relevant to the data model selected for display in
the display window. For example, for a relational model, the icons include New Table, New View, Split
Table, Merge Tables, New FK Relation, Generate DDL, Synchronize Model with Data Dictionary, and
Synchronize Data Dictionary with Model.
Object Browser
The left side of the Data Modeler window has an Object Browser that displays data modeling objects in a
hierarchical tree structure. You can select an object in the object browser by expanding the appropriate
tree node or nodes and then clicking the object.
Navigator
It displays a graphical thumbnail representation of the view that is currently selected in the display window,
to the right of the Object Browser.
Note: The screenshot in the slide displays a relational data model that has already been created.
5
Building an ERD by Using Oracle SQL Developer Data
Modeler
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 6
Oracle SQL Developer Data Modeler
6
Case Scenario: An Introduction
Sean, I would like you to create a simplified
library database to manage the number of
reference books in our department. As a first
step, can you build a logical model using
Oracle SQL Developer Data Modeler that we
Faculty have installed in our student machines?
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 7
Oracle SQL Developer Data Modeler
7
Case Scenario: Identifying Entities
Book
Author
Member Publisher
Book
Transaction
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 8
Oracle SQL Developer Data Modeler
8
Building an Entity Relationship Diagram
1
Navigate to the
Logical Tab
2
Create an Entity
3
Add Attributes to
the Entity
4
Set the Unique
Identifiers
5
Define the Relationship
Between the Entities
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 9
Oracle SQL Developer Data Modeler
9
Building an ERD: Step 1
• Navigate to the Logical tab
−The first step in building an ERD in Oracle SQL Developer Data
Modeler is to click the Logical tab. Notice that the toolbar
changes to display tools specifically for working with ERDs
−If you do not see the Logical tab, then perform the following
steps:
1. Right-click the Logical
Model in the browser
2. Select Show
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 10
Oracle SQL Developer Data Modeler
10
Building an ERD: Step 2
• Create an entity
−To create an entity, perform the following steps:
a. On the toolbar, click the New Entity tool, and then click anywhere in
the white space of the Logical pane. The Entity Properties window
appears
b. In the Entity Properties window, enter the a
name of the entity. For the
example in the slide, the entity
name is "BOOK". Do not close b
the window after you have
entered the entity name
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 11
Oracle SQL Developer Data Modeler
11
Building an ERD: Step 3
• Add attributes to the entity
−To add attributes to the entity, perform the following steps:
a. Select Attributes in the navigator of the Entity Properties window
b. Click the Add an Attribute icon
c. In the Name field,
enter a name for the
attribute a
b c
d
e
f
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 12
Oracle SQL Developer Data Modeler
Data types will be covered in more detail later in the course. For dates, use the DATE type. For text use
VARCHAR, and for numbers NUMERIC.
Attribute size is the maximum number of characters for VARCHAR types.
For NUMERIC datatypes: Precision is the maximum number of digits and Scale is the number of digits after
the decimal point.
Logical types are not actual data types, but names that can be associated with native types.
12
Building an ERD: Step 3
• Add attributes to the entity
d. In the Data type field, select Logical, then required type.
from the dropdown list
e. Enter the attribute size
f. If the attribute is
mandatory, check
the box a
b c
g. Click OK
d
e
f
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 13
Oracle SQL Developer Data Modeler
Data types will be covered in more detail later in the course. For dates, use the DATE type. For text use
VARCHAR, and for numbers NUMERIC.
Attribute size is the maximum number of characters for VARCHAR types.
For NUMERIC datatypes: Precision is the maximum number of digits and Scale is the number of digits after
the decimal point.
Logical types are not actual data types, but names that can be associated with native types.
13
Building an ERD: Step 3
• Add attributes to the entity
−Although Data types are not required in a logical model (they
will not be shown on the ERD) adding them now will allow
Data Modeler to convert them to actual SQL Data types when
we engineer to the Physical (Relational) Model
a
b c
d
e
f
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 14
Oracle SQL Developer Data Modeler
Data types will be covered in more detail later in the course. For dates, use the DATE type. For text use
VARCHAR, and for numbers NUMERIC.
Attribute size is the maximum number of characters for VARCHAR types.
For NUMERIC datatypes: Precision is the maximum number of digits and Scale is the number of digits after
the decimal point.
Logical types are not actual data types, but names that can be associated with native types.
14
Building an ERD: Step 3 cont.
• Set Preferred data types
−You can set commonly used Logical data types as preferred by
performing the following steps:
a. Select Tools > Preferences > Data Modeler, and select the Model
node
b. Select the types from the
All Logical Types section and a
move them to the preferred
area by clicking the arrow
c. Click OK
b
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 15
Oracle SQL Developer Data Modeler
15
Building an ERD: Step 3 cont.
• Set Preferred data types
−To view only the preferred data types, select the Preferred
check box. This will limit the options displayed in the drop-
down list for logical types
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 16
Oracle SQL Developer Data Modeler
16
Building an ERD: Step 4
• Set Primary and Secondary UIDs
−To set the Primary UID for the entity, perform the following
steps:
a. Select Attributes in the left navigator of the Entity Properties
window
b. Select the attribute that
you want to assign as the
Primary UID
c. Select the Primary UID a
check box b
• The attribute that you assign
as primary UID is c
automatically also set to
mandatory
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 17
Oracle SQL Developer Data Modeler
17
Building an ERD: Step 4 cont.
• Set Primary and Secondary UIDs
−To set Secondary UIDs for the entity, perform the following
steps:
a. Select Unique Identifiers in the left navigator of the Entity
Properties window
b. Click the Add icon to a b
add another UID
c
c. Click the Properties icon
d. Enter a name to identify
the Secondary UID d
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 18
Oracle SQL Developer Data Modeler
18
Building an ERD: Step 4 cont.
• Set Primary and Secondary UIDs
e. Select Attributes and Relations from the left navigator of
the Key Properties window
f. Select the attribute to set as a Secondary UID
g. Click the arrow icon
to move the attribute
to the right-hand pane
h. Click OK e g
f
h
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 19
Oracle SQL Developer Data Modeler
19
Building an ERD: Step 5
• Define the relationships between the entities
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 20
Oracle SQL Developer Data Modeler
20
Building an ERD: Step 5 cont.
• Define the relationships between the entities
b
a
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 21
Oracle SQL Developer Data Modeler
21
Building an ERD: Step 6
• Set the source and target values for the relationship
a
− To set the source and target values for the relationship, perform the
following steps:
a. Double-click the relationship
in the diagram b
b. Select the General property c
in the left navigator
c. Specify a name for the
relationship d
d. Specify the source and target
names for the relationship
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 22
Oracle SQL Developer Data Modeler
The source and target optionality and cardinality can be also be modified in the Relation Properties
window.
To mark a relationship as non-transferable, uncheck the Transferable check box at either the source or the
target.
22
Building an ERD: Step 6 cont.
• To display source and target relationship names:
a. Right click on the
whitespace of the
diagram
a
b. Select Show
c. Click Labels
b
c
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 23
Oracle SQL Developer Data Modeler
23
Building an ERD: Step 6 cont.
• To change the path of a relationship line:
a. Right click on the relationship
b. Select Add elbow
c. Drag the center handle to the desired position
c
a
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 24
Oracle SQL Developer Data Modeler
24
Case Scenario: Entity Types
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 25
Oracle SQL Developer Data Modeler
25
Creating the Supertype Entity
• To define an entity as a subtype in Oracle SQL
Developer Data Modeler you need to ensure that the
supertype exists. In this example, the super type is
MEMBER. Perform the following steps to create the
FACULTY subtype:
a. Double-click the entity that you want to make a subtype.
For the example in the slide, you want to make FACULTY a
subtype of the MEMBER supertype. Double-click FACULTY
b. Select the MEMBER supertype entity from the Super Type
list, and click OK. The FACULTY entity is now a subtype of
the MEMBER supertype and will inherit all the attributes of
the supertype
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 26
Oracle SQL Developer Data Modeler
26
Creating the Supertype Entity
MEMBERS Supertype
CORPORATE
a
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 27
Oracle SQL Developer Data Modeler
27
Creating the Arc Relationship
• To create an exclusive relationship in Oracle SQL
Developer Data Modeler, perform the following steps:
a. Hold the ctrl key and select the intersecting entity and both
relationships on which you want to create the Arc
relationship
b. Click the New Arc icon in the toolbar. The
exclusive relationship is created with the arc
a
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 28
Oracle SQL Developer Data Modeler
The business rule for this relationship is read as follows: "Each MEMBERSHIP either may be held by one and
only one STUDENT or may be held by one and only one FACULTY."
28
Creating the Arc Relationship
• To create an exclusive relationship in Oracle SQL
Developer Data Modeler, perform the following steps:
a. Hold the ctrl key and select the intersecting entity and both
relationships on which you want to create the Arc
relationship
b. Click the New Arc icon in the toolbar. The
exclusive relationship is created with the arc
c
b
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 29
Oracle SQL Developer Data Modeler
The business rule for this relationship is read as follows: "Each MEMBERSHIP either may be held by one and
only one STUDENT or may be held by one and only one FACULTY."
29
Creating the Barred Relationship
• To add a barred relationship select Identifying
Relationship from the toolbar, and click the source and
target entities to add the relationship between the
entities
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 30
Oracle SQL Developer Data Modeler
30
Creating the Hierarchical Relationship
• Hierarchical data can be represented as a
set of 1:N relationships (or 1:N Identifying)
• In this example, a University has a hierarchical
structure:
−A FACULTY can consist of one or more
DEPARTMENTS
−A DEPARTMENT can offer one or more
COURSES
• The UIDs for a set of hierarchical entities
can be propagated through multiple
relationships by making the relationships
Identifying
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 31
Oracle SQL Developer Data Modeler
In this example, the UID of COURSE is a composite UID consisting of Course Id, Department Id and Faculty
Id.
31
Creating the Recursive Relationship
• To add a Recursive Relationship, select the required
relationship from the toolbar as normal, then click on
the entity to make it the source, and click on the same
entity a second time to make it the target
Recursive
Relationship
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 32
Oracle SQL Developer Data Modeler
The business rule for this relationship is read as follows: "An employee may be a manager of one or more
employees“. "An employee may be managed by one and only one employee“
32
Project Exercise
• DFo_4_1_Project
−Oracle Baseball League Store Database
−Creating a Logical Data Model
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 33
Oracle SQL Developer Data Modeler
33
Summary
• In this lesson, you should have learned how to:
−Use Oracle SQL Developer Data Modeler to create :
• Entities, attributes, and UIDs with correct optionality and cardinality
• Supertype and subtype entities
• Arc, hierarchical, barred, and recursive relationships
DFo 4-1
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 34
Oracle SQL Developer Data Modeler
34