0% found this document useful (0 votes)
178 views

How To Create Data Modeling Objects in Toad

- The document discusses how to create a physical data model in Toad Data Modeler software. It includes steps to create tables, columns, primary keys, data types, foreign key relationships and a self-referential relationship. - Specific examples are provided on creating the DEPARTMENT, TITLE, PROJECT, and EMPLOYEE tables with the appropriate columns, data types, and primary keys. - Instructions are given on creating non-identifying relationships between the EMPLOYEE and DEPARTMENT tables and between EMPLOYEE and TITLE using the foreign key. - The self-referential relationship in EMPLOYEE using the MANAGER_NO foreign key referencing EMPLOYEE_NO is also explained

Uploaded by

Ravin Ravin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
178 views

How To Create Data Modeling Objects in Toad

- The document discusses how to create a physical data model in Toad Data Modeler software. It includes steps to create tables, columns, primary keys, data types, foreign key relationships and a self-referential relationship. - Specific examples are provided on creating the DEPARTMENT, TITLE, PROJECT, and EMPLOYEE tables with the appropriate columns, data types, and primary keys. - Instructions are given on creating non-identifying relationships between the EMPLOYEE and DEPARTMENT tables and between EMPLOYEE and TITLE using the foreign key. - The self-referential relationship in EMPLOYEE using the MANAGER_NO foreign key referencing EMPLOYEE_NO is also explained

Uploaded by

Ravin Ravin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

How to create Data Modeling Objects in Toad?

Here in this section, we will create a physical data model instead of starting from logical data
model, since we can cover most of the features of a data modeling tool in the physical data
model. Please refer our sections listed under Data Modeling Topic Logical Data Modeling
and Data Modeling Tool - Erwin for creating a logical data model.

Table Structures
EMPLOYEE_PROJE
EMPLOYEE TITLE DEPARTMENT PROJECT
CT
Employee_No Title_Code Department_No Project_Code Employee_No (FPK)
(PK) (PK) (PK) (PK) Project_Code (FPK)
Employee_Na Title_Descripti Department_Na Software_Us
me on me ed
Manager_No
(FK)
Title_Code
(FK)
Department_N
o (FK)
Working with Toad:

• Open Toad Data Modeler Software


• Click Menu File --> New --> Model
• A new window will appear which asks you to select the database on which you will be
generating the physical model
• Since we are doing it in Oracle, select Oracle 11g release 2. Click OK.
• A new screen appears. On the left hands side top, you can see the database name
(Oracle 11g release 2). Below that you can see Physical Model Explorer, which
contain different objects. Physical Model looks similar to a windows explorer.
• On the middle and right hand side, you can see work-space (work area), where we
will be creating objects.

On the tool bar, you can see a list box which displays Captions (Logical Data Model, Names
(Physical Data Model) and Full Names. Select Names.

How to create table 'DEPARTMENT'?

• Click entity icon displayed on the tool bar and drop it on the work area. A new entity
is created. By default some name is provided by the tool.
• Highlight the entity, right click and click edit from the sub menu.
• A new window, which contains different tabs, is opened.
• Under General Tab, change the name and captions to "DEPARTMENT".
• Click Apply and OKAY. Now in the work area, you can see the DEPARTMENT table.

NOTE: Give proper names to TABLES, COLUMNS, PRIMARY KEYS, FOREIGN KEYS,
INDEXES etc. and all other database objects as per the standard maintained by the data
modeling team and database team.

How to create columns, primary keys, data type to table?


1. DEPARTMENT Table:
Column Name Constraint Name Data Type
Department_No Primary Key Integer
Department_Name NOT NULL VARCHAR2 (30)

• Highlight table DEPARTMENT, right click edit from the sub menu.
• Click Tab 'Attributes'. Click Add. By default, an attribute is created. Click edit and
from the new window
o Change name and caption to 'Department_No'.
o Change the data type to Integer.
o Department_No is the primary key of the table. So double click the space
under the key column and you can see the key symbol. Click apply and OK.
Go to the keys tab and change the primary key name to "Department_PK'.
• On the work area, you can see table DEPARTMENT with a column "Department_No"
as the primary key.
• Similarly create column 'Department_Name" with data type as VARCHAR2 (30). It
should not be the primary key and it should be a column in the table. When you
create, you can see a check box under NOT NULL. Check that check box so that this
column will be NOT NULL. Assign data type as VARCHAR2 (30).

Similarly create tables TITLE and PROJECT and add columns to those tables.

2. TITLE Table:
Column Name Constraint Name Data Type
Title_Code (PK) Primary Key Integer
Title_Description NOT NULL VARCHAR2 (30)

3. PROJECT Table:
Column Name Constraint Name Data Type
Project_Code (PK) Primary Key Integer
Software_Used NOT NULL VARCHAR2 (30)
Similarly create table EMPLOYEE with Employee_No as the primary key and
Employee_Name as the column. Later we will add other columns.

4. EMPLOYEE Table:
Column Name Constraint Name Data Type
Employee_No (PK) Primary Key Integer
Employee_Name NOT NULL VARCHAR2 (30)
Non - Identifying relationship:

If a column (foreign key)/multiple columns (foreign key columns) referencing some table
becomes a column in a table as a NON-PRIMARY KEY, and then it is non-identifying
relationship.

How to create non-identifying relationship with cardinality of 1 to many relationship in


Employee Table?
Example 1: Employee Table with Department Table:

Since the relationship is one to many with Department_No (Department Table) and
Department_No (Employee table), we go with Non-Identifying Relationship. In Non-
Identifying relationship, primary key migrates from the Department table to Employee table
and it is not a part of the primary key in Employee table. Here Department_No becomes the
foreign key column and generally Foreign Key relationship is represented by a dotted line.

• Click Non-Identifying relationship in the toolbar.


• Click first on Department table; you can see a dotted line and then click on Employee
table. Now you can see a relationship(dotted line) created between the Department
Table and Employee Table.
• Double Click the relationship. Change the relationship name as required
(EMPLOYEE_FK01).
• Under section CARDINALITY, check Mandatory Parent and Mandatory Child, since
NULL values are not allowed in both the primary key and foreign key columns. Now
the cardinality is 1..1 to 1..n.
• Cardinality describes the relationship between a parent table and a child table. When
you edit properties of the relationship line, you will be requested check(enable) the
check boxes for mandatory parent column, and mandatory child. We have explained
various permutations and combinations below.

Cardinality
Mandator Mandator
Parent Table Child Table Relationshi
y Parent y Child
p

Department.Department_ Employee.Department_
Yes Yes 1..1 to 1..n
No No

Department.Department_ Employee.Department_ Yes No 1..1 to 0..n


No No

Department.Department_ Employee.Department_
No Yes 0..1 to 1..n
No No

Department.Department_ Employee.Department_
No No 0..1 to 0..n
No No

• If you want to change the default foreign key index name, then change the name
(EMPLOYEE_IDX01) in "Index to Foreign Key" tab. You have to double click the
relationship line and there is a tab named "Index to Foreign Key".
• Click apply and ok. You can see how tables are connected and a new column
Department_No is included in the Employee table.

Example 2: Employee Table with Title Table:

Repeat the above same procedure and you can see how Title table and Employee table are
connected. You can see a new column Title_Code is included in the Employee Table.

How to create SELF REFERENTIAL OR RECURSIVE RELATIONSHIP in Employee Table:

When a Foreign key references the parent key(Primary key) of the same table, then it is
called a SELF REFERENTIAL OR RECURSIVE RELATIONSHIP. The column
Manager_No in the Employee table is a Foreign key which takes its values from the column
Employee_No of the same Employee table.

This relationship is created by non-identifying relationship with cardinality 1 to many


relationship in Employee Table:

• Click Non-Identifying relationship in the tool bar.


• Click the employee table twice. You can see the relationship created and a new
column "FK_EMPLOYEE_NAME" appearing within the table. Go to the properties
of that column and change the name to "MANAGER_NO". So this column
'Manager_No" will reference the values from its primary key column 'Employee_No".

You might also like