EXperiment 3
EXperiment 3
EXCERCISE NO. 3
AIM: -
To draw a sample ENTITY RELATIONSHIP DIAGRAM for real project or system.
Hardware Requirements:
Pentium 4 processor (2.4 GHz), 128 Mb RAM, Standard keyboard n mouse, colored
monitor.
Software Requirements:
Rational Rose, Windows XP,
THEORY
Entity Relationship Diagrams are a major data modelling tool and will help organize the
data in your project into entities and define the relationships between the entities. This
process has proved to enable the analyst to produce a good database structure so that the
data can be stored and retrieved in a most efficient manner.
Entity
A data entity is anything real or abstract about which we want to store data. Entity types
fall into five classes: roles, events, locations, tangible things or concepts. E.g. employee,
payment, campus, book. Specific examples of an entity are called instances. E.g. the
employee John Jones, Mary Smith's payment, etc.
Relationship
A data relationship is a natural association that exists between one or more entities. E.g.
Employees process payments. Cardinality defines the number of occurrences of one
entity for a single occurrence of the related entity. E.g. an employee may process many
payments but might not process any payments depending on the nature of her job.
28
Lab Manual- Software Engineering BCS651
.
Attribute
A SIMPLE EXAMPLE
A company has several departments. Each department has a supervisor and at least one
employee. Employees must be assigned to at least one, but possibly more departments. At
least one employee is assigned to a project, but an employee may be on vacation and not
assigned to any projects. The important data fields are the names of the departments,
projects, supervisors and employees, as well as the supervisor and employee number and
a unique project number.
1. Identify Entities
The entities in this system are Department, Employee, Supervisor and Project. One is
tempted to make Company an entity, but it is a false entity because it has only one
instance in this problem. True entities must have more than one instance.
29
Lab Manual- Software Engineering BCS651
2. Find Relationships
We construct the following Entity Relationship Matrix:
4. Fill in Cardinality
From the description of the problem we see that:
30
Lab Manual- Software Engineering BCS651
7. Identify Attributes
The only attributes indicated are the names of the departments, projects, supervisors and
employees, as well as the supervisor and employee NUMBER and a unique project
number.
8. Map Attributes
Attribute Entity Attribute Entity
Department Department Supervisor Supervisor
Name Number
Employee Employee Supervisor Supervisor
Number Name
Employee Employee Project Project
Name Name
Project Project
Number
31
Lab Manual- Software Engineering BCS651
32
Lab Manual- Software Engineering BCS651
FURTHER DISCUSSION:
The second symbol gives the maximum number of instances of the entity joining the
connector for each instance of the entity on the other side of the relationship. If there is
only one such instance, this symbol is 1. If more than 1, the symbol is a crows foot
opening towards the rectangle.
If you read it like a sentence, the first entity is the subject, the relationship is the verb, the
cardinality after the relationship tells how many direct objects (second entity) there are.
33
Lab Manual- Software Engineering BCS651
.
Step 5. Define Primary Keys
For each entity we must find a unique primary key so that instances of that entity can be
distinguished from one another. Often a single field or property is a primary key (e.g. a
Student ID). Other times the identifier is a set of fields or attributes (e.g. a course needs a
department identifier, a course number, and often a section number; a Room needs a
Building Name and a Room Number). When the entity is written with all its attributes,
the primary key is underlined.
Fortunately, by introducing an extra entity, called an associative entity for each many-to-
many relationship, we can solve this problem. The new associative entity's name will be
the hyphenation of the names of the two originating entities. It will have a concatenated
key consisting of the keys of these two entities. It will have a 1-1 relationship with each
of its parent entities and each parent will have the same relationship with the associative
entity that they had with each other before we introduced the associative entity. The
original relationship between the parents will be deleted from the diagram.
The key-based ERD has no many-to-many relationships and each entity has its primary
and foreign keys listed below the entity name in its rectangle.
34
Lab Manual- Software Engineering BCS651
Even if you have no new entities to add to the Key-Based ERD, you still need to add the
attributes to the Non-Key Data section of each rectangle. Adding these attributes
automatically puts them in the repository, so when we use the entity to design the new
system, all its attributes will be available.
Conclusion: The entity relationship diagram was made successfully by following the
steps described above.
35