How to add identifying, non-identifying, self-recursive relationship in ER Studio Data Architect?

Now, we are going to make changes to the previously created data model. So create another file LDM_creating_entity_version2. Open the previous data model “LDM_creating_entity_version1” and click menu file/save as “LDM_creating_entity_version2”.

How to add entity and attributes in ER Studio Data Architect:

Add the following attributes to “Employee” Entity. Place the cursor in attribute section of Employee Entity, right click edit entity. Click attributes tab and add the following attributes.

  • “Employee Name” with data type as Varchar(50); NOT NULL;
  • “Incentive Indicator” with datatype as Char(10);  NOT NULL;
  • “Phone Number” with datatype as Char(12); NULL;

You can use UP or DOWN arrow keys to align the attributes.

Create another entity Address with Address Identifier as attribute, datatype as Integer and Address identifier as primary key.

Address ID should be a sequence number.

How to create a sequence number in ERStudio Data Architect:

When you add an attribute, you can see a section “Identity Property”.  Click the check box in Identity column.

Type 1 for seed and 1 for increment. Seed means the starting number of the sequence and increment means how it has to be incremented.

Create another entity Employee-Address with no attributes.  We will explain how to add attributes below.

How to add non-identifying relationship in ER studio data architect?

Department entity to Employee entity:

Many employees can work in one department. One-to-many relationship. Hence we can create this relationship by Non-Identifying Relationship.

Click menu Insert/Relationship/Non-Identifying mandatory:

Click the cursor on Department Entity and then on Employee Entity.

Now you can see the non-identifying relationship between department entity and employee identity.

A new attribute Department Number is added to employee entity.

How to add identifying relationship in ER studio data architect?

Employee entity and Address entity: One employee can stay in many addresses.

One address can contain many employees.

Many to many relationship: Identifying relationship

Create address entity with address id as the primary key.

Click menu Insert/Relationship/Identifying

Click the cursor on employee entity and employee address entity. Again click on address entity and then on employee-address entity.

Now you can see the identifying relationship in employee address entity.

Two new attributes employee number, and address identifier are added as primary keys to employee-address entity. Since two keys are there, it is called as composite primary keys.

How to add self-recursive relationship in ER studio data architect?

To connect relationship between an employee and a manager: There is no attribute which references the employee number in the employee entity.  So we will create a new attribute Manager Number by using self-recursive relationship. When we want to create an attribute in an entity that references the same primary key attribute, we have to create role name, because, two attributes cannot have the same name in the same table.

In this example, the parent entity and child entity are same (employee entity).

Click menu Insert/Relationship/Non-Identifying mandatory

Click the cursor on employee entity twice. You can see a new screen. Type role name as manager number.

You can see a new attribute manager number in employee entity.

If you want to know more about the relationship, click each relationship line and you can see different options.

02_identifying_and_non_identifying relationship

 

Leave a Reply

Your email address will not be published. Required fields are marked *