How To Create Data Modeling Objects in Toad
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:
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.
• 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.
• 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.
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.
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_
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.
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.
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.