You are on page 1of 4

System Analysis and Design (ISYS10242

Lab Session 7
Entity Relationship Diagram (ERD) in RSA

In this lab you will practice how to design a database structure in RSA and illustrate it in ERD
format.
In the next lab, you will continue working with the database that you will create this week.
Therefore, make sure you save your work in your own network space or on your own memory
stick to be used in the next lab session.

Task 1: Create a new data project


Note that unlike the previous labs, we do not create a model project. Create a new data project by
completing these steps:

1. Click File > New > Project.


2. Scroll up in the list and select “Data Design Project”.
3. Name the project 'My Data Design Project' and click Finish.
4. You may be asked to open “Data Perspective” as the default perspective for such a data
project. In this case, Click on “Yes”.

Task 2: Create your first ERD


Create a blank ERD (also called “physical data model” in RSA) by completing these steps:

1. In the “Data Project Explorer”, expand the folder of your new project. Then right-click on
“Data Models” and select “New” -> “Physical Data Model”.
2. You will be asked about the file name and database type. You do not need to change
anything. Press “Finish”.
3. You will see that a new diagram called “Diagram1” is created for you. Your Data Project
Explorer should look like the following:
Task 2: Design an ERD for an employee database
Your aim is to generate an ERD for a company that has a number of employees working in a
number of projects in different departments. For now, assume that each employee is allocated to a
project and works in a department.
You see that three entities (tables) are to be designed: Employee, Project and Department. The
required attributes and their data types for the three tables are:
 Project:
o projectCode (text, 10 letters) - PK
o projectTitle (text, 20 letters)
o projectManager (text, 20 letters)
o projectBudget (number, int)
 Department:
o departmentNo (text, 10 letters) – PK
o departmentName (text, 20 letters)
 Employee
o employeeNo (text, 10 letters)
o employeeName (text, 20 letters)
o departmentNo (text, 10 letters) - FK to the same attribute in Department table
o projectCode (text, 10 letters) – FK to the same attribute in Project table
o hourelyRate (number, float)
The ERD that you will develop should look like the following:
Double click on “Diagram1”. On the right side, under “palette”, expand the “Data” folder and you
will see the different ERD elements ready to be added, as shown here:

Now add elements to this ERD by completing these steps:

1. To add a class, drag and drop a “Table” from the Palette to an empty space in the diagram.
2. To change a table name, select it (click on its border), then start to type its new name.
3. To add a primary key (PK) attribute to a table, select the table (click on its border), right-
click, then select “Add data object) -> Key. You may then rename the attribute.
4. To add other attributes (including FKs), right-click, then select “Add data object) ->
Column.
5. To change the data type of an added attribute, select the attribute, when it is highlighted, in
“Properties” tab (located below the diagram), under “Type”, choose the data type from the
available drop-down lost and its length (if applicable). There is a number of similar
choices for text attributes. You may choose “CHAR” (selected as default) and specify the
length.

Now you may make relationships between the tables. To do that, follow these steps:

1. We need a one-to-many relationship between Project and Employee based on the shared
attribute “ProjectCode” (why?). To establish this, choose “Non-Identifying Mandatory”
relationship icon from the Palette, then draw a relationship from “Project” table to
“Employee).
2. Because the PK of the source table (Project) already exists in the destination table
(Employee), you may be asked whether you would like to establish the relationship based
on the existing attributes, or you would like RSA to add extra attribute to support the
relationship. In this case, select reusing the existing attributes.
3. You will see that a new dashed line is drawn between the tables showing multiplicity icons
on the two sides. You should see the “one” on the “Project” side and a “many” on the
“Employee” side.
4. You also notice that there are two labels around the relationship, one reads “verb1” and the
other is a long name containing the PK-FK relationship. Click on the long label, and press
delete as we do not need this level of details now. Click on the “verb1”, then from the
Properties window (below the diagram), select “Details” tab and rename the label to
“works for” (to show that an employee works for a project).
5. Do the above steps to establish another one-to-many relationship between “Department”
and “Employee” tables based on the shared attribute “departmentNo”.

Your ERD should now look like the diagram shown in page 2.
Task 2: ERD design improvement
Assume that after a change in the company policy, now employees can be allocated to different
projects at the same time. Moreover, they can be paid differently for their time in different
projects. Your task is to improve the ERD in order to accommodate the new changes.
Notice that the required relationship between “Employee” and “Project” tables is now a “many-to-
many” relationship, since an employee can be allocated to many projects, and a project can be
allocated to many employees. This could be directly shown on a UML class diagram (by labelling
0…* multiplicities on the both sides). However, in a physical database design, you need to treat
this situation by adding an extra table which has a couple of “one-to-many” relationships with
“Employee” and “Project” tables. This process is called “resolution” too.
We call this new table “Allocation” which has the following structure:
 Allocation
o allocationID (text, 10 letters) - PK
o employeeNo (text, 10 letters) – FK to the same attribute in Employee table
o projectCode (text, 10 letters) – FK to the same attribute in Project table
o hourlyRate (number, float)
Note that “departmentNo [FK]” attribute should not be in “Employee” table anymore. Also note
that “hourlyRate” which was previously an attribute of “Employee” table, is now moved to the
new “Allocation” table (why?).
Now that you know the rationale behind the ERD improvement, modify your ERD by adding the
new table and changing the relationships accordingly. To move an attribute between two tables,
simply drag and drop it.
Now your new ERD should look like the following:

Review the solution


The solution for this lab is available to download from the module’s page on NOW.

You might also like