Before You Begin
Purpose
This tutorial covers how to make changes to your database using the relational model in Oracle SQL Developer Data Modeler Release 4.1.
Time to Complete
Approximately 60 minutes
Background
Oracle SQL Developer Data Modeler is a tool that enables you to diagrammatically display your database objects, make changes, and update the schema based on the changes quickly and easily. It is a standalone, independent product available for download and free use.
You can import from and export to a variety of sources and targets. You also have a variety of formatting options and can validate the models through a predefined set of Design Rules. By using this tool, you can connect to any Oracle supported database.
Scenario
In this tutorial, you use Oracle SQL Developer Data Modeler Release 4.1 to perform the following:
Import two tables (EMPLOYEES and DEPARTMENTS) from the HR schema into SQL Developer Data Modeler.
Add a new table (PROJECTS), join it to the DEPARTMENTS table and create a new column (COST_CENTER) in the DEPARTMENTS table.
Reverse engineer the relational model to a logical model.
Modify the model by creating a new Entity with Attributes and relations.
Synchronize the logical with the Relational Model.
Generate the DLL with the changes you made.
What Do You Need?
Access to a database in Oracle Database 12c with the sample schema installed
Note: This tutorial was created in a Linux environment. If you are using a Windows environment, the screenshots may be slightly different.
Importing Tables from HR Schema
In this topic, you create a connection to the HR schema. You then use this connection to import the EMPLOYEES and DEPARTMENTS tables into SQL Developer Data Modeler.
Open SQL Developer Data Modeler.
You now import the tables from the data dictionary. From the File menu, choose Data Modeler, Import, and then Data Dictionary.
View ImageDescription of this image The Data Dictionary Import Wizard opens. Click Add to create a connection to the database.
View ImageDescription of this image A New / Select Database Connection dialog opens. Enter the connection details and click Test.
Connection Name: hr_orclpdb
Username: hr
Password: <your_password>
Hostname: localhost
SID / Service name: <your_own_SID> / <your_own_servicename>
View ImageDescription of this image Note: In this tutorial, the Service Name is specified instead of SID.
If all the details are entered correctly, the status is Success. Click Connect.
View ImageDescription of this image In the Data Dictionary Import Wizard, select the hr_orclpdb connection you just created and click Next.
View ImageDescription of this image You want to import only the HR schema. Select only the HR schema and click Next.
View ImageDescription of this image Select the DEPARTMENTS and EMPLOYEES tables and click Next.
View ImageDescription of this image Click Finish to generate the design.
View ImageDescription of this image Review the log file created and click Close.
View ImageDescription of this image The EMPLOYEES and DEPARTMENTS tables are successfully imported into a relational model within SQL Developer Data Modeler. If the tables do not line up correctly, drag the object and realign accordingly.
View ImageDescription of this image The table and relations are repositioned.
View ImageDescription of this image
Reviewing the Physical Model
In this topic, you review the physical model that is automatically created when you import the objects from the data dictionary.
From the View menu, choose Data Modeler and then Browser.
The Browser window gets docked to SQL Developer under Reports. In the Browser, expand Relational Models followed by hr_orclpdb, Physical Models, Oracle Database 12c, Tables, HR.DEPARTMENTS, and Columns in the order specified here.
View ImageDescription of this image -
Review the list. Note the other objects available in the Physical Model.

Creating a New Table
In this topic, you create a PROJECTS table. The PROJECTS table has four columns: PROJECT_ID, PROJECT_NAME, PROJECT_START_DATE, and PROJECT_END_DATE.
Click the New Table icon from the Oracle SQL Developer Data Modeler toolbar and click the white space of the diagram..
View ImageDescription of this image A Table Properties dialog opens. Enter PROJECTS for Name and click Columns on the left-navigator.
View ImageDescription of this image Click the Create Column icon to add a column.
View ImageDescription of this image In the Column Properties section, enter the following values and click Create Column.
Name: PROJECT_ID
Datatype: Logical
Source Type: NUMERIC
Precision: 6
PK: <enabled>
View ImageDescription of this image Add another column. In the Column Properties section, enter the following values and click Create Column.
Name: PROJECT_NAME
Datatype: Logical
Source Type: VARCHAR
Size: 100
Add another column. In the Column Properties section, enter the following values and click Create Column.
Name: PROJECT_START_DATE
Datatype: Logical
Source Type: Date
Add the last column. In the Column Properties section, enter the following values and click OK to create the table.
Name: PROJECT_END_DATE
Datatype: Logical
Source Type: Date
View ImageDescription of this image The table is created successfully. Reposition the table, if required.
View ImageDescription of this image
Joining the New Table to the Existing Table
In this topic, you create a foreign key between the PROJECTS table and the DEPARTMENTS tables.
Click the New Foreign Key icon from the Oracle SQL Developer Data Modeler toolbar.
View ImageDescription of this image To create a foreign key in the PROJECTS table, click the DEPARTMENTS table and then click the PROJECTS table.
View ImageDescription of this image A Foreign Key Properties dialog opens. In the Associated Columns section, confirm that DEPARTMENTS_DEPARTMENT_ID is selected for Column and click OK.
View ImageDescription of this image The Foreign Key Relation is created. The 'F' against DEPARTMENTS_DEPARTMENT_ID in the PROJECTS table identifies the column as a foreign key.
View ImageDescription of this image To make the Foreign Key optional, right-click the line joining the two tables and select Properties.
View ImageDescription of this image Deselect both the Mandatory checkbox and click OK.
View ImageDescription of this image Click Yes in the dialog box to disable a mandatory Foreign Key.
View ImageDescription of this image The Foreign Key is now optional, which means that you can now have a Project without a Department.
Modifying an Existing Table
In this topic, you add the COST_CENTER column to the DEPARTMENTS table.
In the diagram, double-click the DEPARTMENTS table.
Select the Columns property from the left navigator and click the Create Column icon.
In the Column Properties section, enter the following values and click OK to create the column.
Name: COST_CENTER
Datatype: Logical
Source Type: VARCHAR
Size: 25
View ImageDescription of this image The COST_CENTER column is successfully created in the DEPARTMENTS table.
View ImageDescription of this image
Reverse Engineering the Relational Model to Create a Logical Model
With the relational model diagram window open, select the Engineer to Logical Model icon in the toolbar.
View ImageDescription of this image The Engineer to Logical Model window appears. Expand Tables and click Engineer.
View ImageDescription of this image The Logical Model is displayed. Review the entities and attributes. The diagram for the Logical Model is called the Entity Relationship Diagram (ERD).
View ImageDescription of this image
Modifying the Logical Model
You now add some attributes to the PROJECTS entity. Double-click the PROJECTS entity in the ERD.
Select the Attributes property in the left navigator.
Click the Add Attributes icon.
View ImageDescription of this image In the Attribute Properties section, enter the following values and select the DEPARTMENT_DEPARTMENTS_ID attribute from the list.
Name: STATUS
Datatype: Logical
Source Type: VARCHAR
Size: 30
The DEPARTMENT_DEPARTMENTS_ID attribute is shown as a result of the relation between the DEPARTMENTS and PROJECTS entities. Notice that you can not change the name of the attribute. You do want to change the name so you change one of the preference settings and click OK.
View ImageDescription of this image Notice that the STATUS attribute was added to the PROJECTS entity and that the DEPARTMENT relation is not displayed on the diagram. Currently you are viewing the Barker notation which does not show the relation attributes. Later in this section you change the notation to the Bachman notation which does display the relation attributes in the diagram.
View ImageDescription of this image You want to change the default so that you can change the name of the relation attribute. Select Tools from the toolbar and choose Preferences.
View ImageDescription of this image In the Preferences window, expand Data Modeler, Model and choose Logical. Deselect the checkbox for Name - Keep as the name of the Originating attribute and click OK.
View ImageDescription of this image Double-click the PROJECTS entity again and ensure that the Attributes property is selected in the Entity Properties window.
Select the DEPARTMENT_DEPARTMENT_ID attribute from the list.
Notice that the Name field is now enabled so you can change its name. Change the name to PROJECT_DEPT and click OK.
View ImageDescription of this image Change the notation to the Bachman notation. Right-click the white space in the diagram to show the context window and select Bachman Notation.
View ImageDescription of this image Notice the notation has changed. You now see the relation attributes (noted with the 'F') as well as the Primary Key attributes. The '*' before each attribute indicates that it is a mandatory attribute.
View ImageDescription of this image Now you add another entity to the Logical Model. Select the New Entity icon in the toolbar and click the white space in the Logical diagram.
View ImageDescription of this image In the General tab of the Entity Properties window, enter TASKS for Name and click the Attributes property in the left navigation.
View ImageDescription of this image Click the Add Attribute icon.
In the Attribute Properties section, enter the following values and click the Add Attribute icon to add another attribute.
Name: TASK_ID
Datatype: Logical
Source Type: NUMERIC
Precision: 6
Primary UID: <enabled>
Again, in the Attribute Properties section, enter the following values and click the Add Attribute icon to add another attribute.
Name: TASK_NAME
Datatype: Logical
Source Type: VARCHAR
Size: 255
Again, in the Attribute Properties section, enter the following values and click the Add Attribute icon to add another attribute.
Name: COST
Datatype: Logical
Source Type: NUMERIC
Precision: 6
Add the last attribute. In the Attribute Properties section, enter the following values and click OK to create the entity and its attributes.
Name: BUDGET
Datatype: Logical
Source Type: NUMERIC
Precision: 6
View ImageDescription of this image Reposition the table in the Logical Diagram, if required. You now create relations between the EMPLOYEES and TASKS, and the PROJECTS and TASKS entities. Select the New 1:N Relation icon in the toolbar.
View ImageDescription of this image Click the EMPLOYEES entity and then the TASKS entity.
View ImageDescription of this image The Relation Properties window opens. Click OK to create the relation.
View ImageDescription of this image Now you create the second relation. Click the PROJECTS entity and then the TASKS entity.
The Relation Properties window opens. Click OK to create the relation.
The relation is displayed. You now change the name of the relation in the TASKS entity. Double-click the TASKS entity.
View ImageDescription of this image In the Entity Properties window, select the Attributes property from the left navigation. Then, choose the EMPLOYEES_EMPLOYEE_ID attribute from the list.
In the Attribute Properties, change the Name of the EMPLOYEES_EMPLOYEE_ID attribute to ASSIGNED_TO. Then, click the PROJECTS_PROJECT_ID attribute from the list.
Change the name of the PROJECTS_PROJECT_ID to PROJECT_ID and click OK.
View ImageDescription of this image Verify that the changes to the logical model are complete.
View ImageDescription of this image
Synchronizing the Logical Model with the Relational Model
With the logical model diagram window open, select the Engineer to Relational Model icon in the toolbar.
View ImageDescription of this image The Engineer to Relational Model window appear. Expand Entities, PROJECTS, and then Attributes. Note the differences and click Engineer.
View ImageDescription of this image In the Relational Model, note that the new STATUS column, the name change PROJECT_DEPT for the foreign key, and the new TASKS table.
View ImageDescription of this image
Generating the DDL to Update the Database
Now that your models are complete, you synchronize the data dictionary with the model and generate the Data Definition Language (DDL) statements.
Select the Synchronize Data Dictionary with Model icon in the toolbar.
View ImageDescription of this image The Data Dictionary Connections dialog opens. Select the Redirect Connection from the select list and click OK.
View ImageDescription of this image The design is generated and the Compare Models dialog opens. Nodes where changes have been made are marked with a triangle icon. In this case, the tables node is marked. Expand the Tables node to see the new tables for PROJECTS and TASKS. Notice that the DEPARTMENTS table has changed.
View ImageDescription of this image Expand DEPARTMENTS and then Columns. The COST_CENTER column will be added. Click DDL Preview.
View ImageDescription of this image The code generated is displayed. Review the CREATE and ALTER statements. Note that the PROJECTS and TASKS tables will be created and altered to create the Primary Keys. Scroll down to the bottom of the page.
View ImageDescription of this image On this page, you see the new column, foreign key constraints. Click Save.
Note you can execute this script in SQL Developer to update the database.
View ImageDescription of this image In the Save DDL Locally window, specify the location where you want to save the DDL statements file, enter the File Name, and click Save.
Click Close to close the Compare Models window.
To save the model, click File, Data Modeler, and choose Save.
View ImageDescription of this image In the Save Design window, specify the location where you want to save the design file, enter the File Name, and click Save.
Close Oracle SQL Developer Data Modeler.