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

Toad Data Modeler Demo Tutorial

The document provides instructions for creating an entity relationship diagram in Toad Data Modeler to model a simple customer orders database for PostgreSQL, including creating entities for customers and products, a many-to-many relationship between them implemented through an orders table, and generating SQL code from the diagram.

Uploaded by

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

Toad Data Modeler Demo Tutorial

The document provides instructions for creating an entity relationship diagram in Toad Data Modeler to model a simple customer orders database for PostgreSQL, including creating entities for customers and products, a many-to-many relationship between them implemented through an orders table, and generating SQL code from the diagram.

Uploaded by

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

First open Toad Data Modeler and create a new project if you would like.

From the file menu, select new model and select PostgreSQL 10. This is important to ensure your
schema is generated correctly for our database.

You should now have an empty workspace. Remember we are modelling E/R diagrams: entities are
tables and attributes are columns.

Let’s make a simple diagram for modelling a database for customers orders. To begin, we should create
an entity for customers and another for the items that they can order.

Depending on your layout, you should have a section of your toolbar for Model Objects. From here, you
can select a new entity or various relationships between them.

Select the option on the farthest left in the red box of the screenshot above, this is your entity tool.
With the entity tool selected, click somewhere in your workspace. An empty entity will appear.

Double click on the newly created entity to edit its properties.

You can set the name of your entity/table in the Caption field, outlined in red. The tab we’re mostly
interested in is Attributes, outlined in green. You can add and edit attributes by selecting the buttons in
the purple region. Additionally, you can edit the order in which attributes are displayed by using the
arrows outlined in blue.
Let’s give our first entity a name, we’ll call it Customer, and let’s add an attribute while we’re at it.

As you can see, an attribute has appeared with all the default information set. Let’s go ahead and
double click on the new attribute and edit its properties.

Once again, you can set the attribute name by editing Caption. We should set a data type as well. In
Postgres a simple string data type is character varying. For our example, we will choose Name as the
primary key for our Customer table. We’ll add another attribute called Address, and we’ll make it not
null as we want every customer to have a valid address.
Now that we can store our customer data, lets make another entity for items/products that they can
buy.

Now that we have customers and products, we are interested in storing the orders that customers
make. Obviously, we will need another table to facilitate this. Note that customers can place multiple
orders and products can be ordered by multiple customers. This means we would like a many-to-many
(M:N) relationship between the two tables.

Refer to the Model Objects toolbar again (where you selected the entity tool) and choose M:N
relationship. Click on both tables to draw the relationship.

Notice that a M:N relationship introduces a third table (which is exactly what we need!), we’ll go ahead
and edit it’s name to be Orders. Orders now has two primary keys, customer name and product name.
Since these are also primary keys for other tables they have been denoted as a primary foreign key.

Continued below
In the case that we wish to add constraints to these relationships, i.e. customer can only order one item,
we can double click on the relationship and edit its cardinality. In our example, we’ll double click on the
relationship between customer and orders.

Notice the Cardinality section above. We’ll adjust the Cardinality from N to 1. Now the relationship
reads: one customer has zero or one order at max.

Now we have a simple database that can store information about customers, products and the orders
that they place.

We only used one type of relationship in this example, but there are two more. Identifying and non-
identifying. An example of each is shown below. A non-identifying relationship is when a primary key of
a table is used as the foreign key in another. An identifying relationship is when a primary key of a table
is used as the primary key in another.
To wrap it up, click the green play button in the top tool bar “Generate DDL Script”. This will generate
the SQL code for our schema, they we can then execute in Postgres to create our database and tables.

You might also like