Chapter 2
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
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.