Relationships in ER diagrams for Oracle Database

Relationships are the connections between tables that establish how data in one table is related to data in another table. Read more about database relationships.

How to create relationships in ER diagram for Oracle Database

To create a new relationship between two tables in Luna Modeler, click the Relationship button on the main toolbar and then click parent and child tables in your ER diagram.

In this example, click table CUSTOMER and then table CART.

Two database tables in ER diagram for Oracle Database.

The new relationship line appears in the diagram and column CUSTOMER_ID is added to the child table CART automatically.

A relationship created between two Oracle Database tables

By default, the primary key is used for the relationship. If you wish to change the primary key, select the parent table and modify the primary key.

Creating relationships in case a column already exists in the child table

You can easily model new relationships by clicking on a column in a parent table and then on a column in a child table. Luna Modeler automatically uses the primary key (or creates an alternate key in the parent table) and maps the relationship to the selected column in the child table.

In this case, new column will not be automatically added to the child table.

Alternate keys

To create a new alternate key, click the +Add key button in section Keys.

How to add an alternate key to Oracle Database table

The new key appears in the child table. Click +Add Column to Key and select a column.

Compound keys

In case you need to create a compound key, for example, a key that should contain columns name and surname, repeat the process twice.

Creation of compound keys in projects for Oracle Database

Usage

To use the compound/alternate key instead of the primary key, select the relationship and navigate to section Keys.

Compound key used in ERD in Luna Modeler.

Change the value in the key dropdown to the new alternate key name. The tool removes the CUSTOMER_ID column from the child table and adds there both the columns defined in the alternate key: CUSTOMER_NAME and CUSTOMER_SURNAME.

Alternate key selection in Luna Modeler

Changing the mapping of columns in the child table

In case you want to use another existing column in the child table for the relationship, select the desired column from the drop-down menu in the Keys -> Columns section.

Changing of table column for a database relationship.

Cardinality

Cardinality settings affect the display of relationships in your diagram. Select a relationship and change values in section Cardinality.

Optional child settings change the appearance of line ending to circle. And if you set cardinality to one, the relationship line will be displayed without the crows’ foot notation graphics.

Cardinality settings for relationships in ER diagrams for Oracle Database

Primary foreign keys

If you set a foreign key column in a child table to the primary key, the color of the key/graphics changes to blue.

Primary foreign key defined in a table for Oracle Database

Referential integrity

To change referential integrity settings, select a relationship and modify values in section Referential integrity.

Generated SQL script for the Oracle Database relationship

Self-relationships

To create a self-relationship, click the Relationship item on the toolbar and then click one table in the diagram twice (not double click it, wait a moment before you click the same table again.)

Self-relationship in ER diagram

#

DATA MODELING TOOLS
DRAW Diagrams and
GENERATE Scripts
Download data modeling tools
Blog Categories
Blog by Platforms