Chapter 2.
Entity-Relationship Model
Exercise 1
Describe the entity relationship diagrams given in the following figures.
Exercise 2
Draw an entity relationship diagram for the following application in an industrial factory:
• There can be many suppliers
• Each supplier has a unique name
• Each supplier can supply many parts to the factory. Each part can be supplied by many
suppliers
• Each part has a unique part number
• Each part has a color
• A supplier can only supply a fixed quantity of each part
Exercise 3
Consider the Teach relationship between Teachers and Subjects. For each of the following
situations, draw an entity relationship diagram
• Each teacher teaches only one Subject
• Each teacher must teach several Subjects
• Each teacher teaches only one Subject, and every subject must be taught by several
teachers
• Teachers can teach the same Subject in many semesters, and need to keep records of all
teaching semesters
• Teachers can teach the same Subject in many semesters, but only need to keep records of
the current semester
• A Subject can be taught by a group of Teachers
Additional attributes, entities, and relationships may be used as needed
Source: Bài giảng Nguyễn Kim Anh. http://cnx.org/contents/a86b84d0-cd65-49ac-9adc-
cdf95d7e8db7@1
Exercise 4
Define an entity relationship diagram for a university management database, which stores
information about Departments, Institutes, Lecturers, Students, Subjects, Classes, Buildings,
Rooms, and Scores. The model should store the following information:
• For each Institute: Name, Address, Institute Head, list of Staff
• For each Department: Name, Affiliated Institute, Department Head
• For each Lecturer: Name, Date of Birth, Position, Lecturer Code, Institute, Office Room,
List of Subjects, List of Classes
• For each Student: Name, Date of Birth, Student Code, list of Subjects studied, scores for
subjects studied
• For each Subject: Subject Code, Subject Name, Semester, list of Lecturers, list of
Students, list of Classes
• For each Class: Class Type (Theory, Practice, Self-Study), Start/End Date, Class Time,
Lecturer, list of Students, Location
• For each Building: Name, Corresponding Map
• For each Room: Name, Capacity, Room Type (Office, Lecture Hall, Laboratory, Practice
Room), Building Name.
Assumption: Lecturers teach the subjects they have registered for. They can teach different
classes of the same subject. And each class is taught by only one Lecturer.
Exercise 5
Define an entity relationship diagram to describe the following database:
• Patients are identified by an SSN. The patient's name, address, and age need to be
recorded.
• Doctors are identified by an SSN. For each doctor, the name, specialty, and years of
experience need to be recorded.
• Each Pharmacy has a name, an address, and a phone number. Each Pharmacy has a
manager.
• Pharmacists are identified by an SSN. Pharmacist can only work in one pharmacy. For
each pharmacist, the name and qualifications need to be recorded.
• For each type of drug, the name, manufacturer, and dosage need to be recorded.
• Each pharmacy can sell many types of drugs, each with its own price. A drug can be sold
at many pharmacies, and the price varies between pharmacies.
• Doctors prescribe drugs to patients. A patient can receive many prescriptions from many
doctors. A prescription can contain one or more medications. Each prescription has a date,
and the corresponding medication type and quantity.
Source: Bài giảng Nguyễn Kim Anh. http://cnx.org/contents/a86b84d0-cd65-49ac-9adc-
cdf95d7e8db7@1