Lecture - 10
Lecture - 10
ERDs, also called ER diagrams or ER models, are used to describe data and how pieces of data
interact with one another. For this reason, ERDs are extremely important in database design
and projects that require a clear structure of all data — think of it as the standardized way to
draw a database diagram. By applying this standard, your team can easily understand the
structure of a database or the information you collect within your system.
ER diagrams help to explain the logical structure of databases. ER diagrams are created based
on three basic concepts: entities, attributes and relationships.
Start by identifying the “what”s in your system or architecture. Entities are represented with
a rectangle.
2. Add Attributes to Each Entity
Next, consider the attributes that you need to describe each entity. These are drawn and
labelled inside ovals. Connect these to the relevant entity and position your attributes.
Let us suppose that we have an employee table. A manager supervises a subordinate. Every
employee can have a supervisor except the CEO and there can be at most one boss for each
employee. One employee may be the boss of more than one employee. Let’s suppose that
REPORTS_TO is a recursive relationship on the Employee entity type where each Employee
plays two roles.
1. Supervisor
2. Subordinate
Supervisor
Employee Supervises
1
N
Supervised
N
Player Play with
Case Study –
A General Hospital consists of a number of specialized wards (such as Radiology, Oncology,
etc). Information about ward includes unique name, total numbers of current patients. Each
ward hosts a number of patients, who were admitted by a consultant (doctors) employed by
the Hospital. On admission, the date and time are kept. The personal details of every patient
include name, Medical Recode Number (MRN), set of phones and one address (city, street,
code). A separate register is to be held to store the information of the tests undertaken. Each
test has unique episode No., category and the final result of test. Number of tests may be
conducted for each patient. Doctors are specialists in a specific ward and may be leading
consultants for a number of patients. Each patient is assigned to one leading consultant but
may be examined by other doctors, if required.
draw an ER diagram to represent the data requirements as following:
– Identify the main entity types.
– Identify the main relationship types between the entity types.
– Identify attributes and associate them with entity or relationship types.
– Determine candidate and primary key attributes for each (strong) entity type.
– Determine the multiplicity constraints for each relationship. State any
assumptions necessary to support your design.