Eroxl's NotesGraph
Entity-Relationship Diagrams (Practice)

Problem 1

Explain the following terms briefly: attribute, domain, entity, relationship, entity set, relationship set, one-to-many relationship, many-to-many relationship, participation constraint, overlap constraint, covering constraint, weak entity set, aggregation, and role indicator.

  • Attribute: Atomic data associated with an entity..
  • Domain: The range of permissible values for an attribute.
  • Entity: An object which can be uniquely identified.
  • Relationship: The natural associations between entities.
  • Entity Set: The set of all instances of a given entity.
  • Relationship Set: The set of all instances of a given relationship.
  • One-to-Many Relationship: A relationship which is associated on the one side with at most one instance of an entity and on the many side any number of instances of an entity.
  • Many-to-Many Relationship: A relationship which is associated with any number of instances of an entity on both sides.
  • Participation Constraint: Constraints defining whether or not an entity must be in a given relationship or not.
  • Overlap Constraint: Constraints defining if a superclass entity instance can appear in multiple subclass instances.
  • Covering Constraint: Constraints defining if a superclass instance must appear in at least one subclass.
  • Weak Entity Set: An entity set that can not be uniquely identified by it's own attributes.
  • Aggregation: Logical grouping of entities participating in a relationship to allow the relationship to participate in a relationship.
  • Role Indicator: A label applied to the edges of a relationship to express which role a given entity plays in the relationship.

Problem 2

A university database contains information about professors (identified by social security number, or SSN) and courses (identified by courseID). Professors teach courses; each of the following situations concerns the Teaches relationship set. For each situation, draw an ER diagram that describes it (assuming no further constraints hold).

(a). Professors Can Teach the Same Course in Several Semesters, and Each Offering Must Be Recorded

(b). Professors Can Teach the Same Course in Several Semesters, and only the Most Recent such Offering Needs to Be Recorded. (Assume This Condition Applies in All subsequent questions.)

(c). Every Professor Must Teach Some Course

(d). Every Professor Teaches Exactly One Course (no More, no less)

(e). Every Professor Teaches Exactly One Course (no More, no less), and Every Course Must Be Taught by Some Professor

(f). Now Suppose that Certain Courses Can Be Taught by a Team of Professors Jointly, but it is Possible that no One Professor in a Team Can Teach the Course. Model This Situation, Introducing Additional Entity Sets and Relationship Sets if Necessary

Problem 3

Consider the following information about a university database:

  • Professors have an SSN, a name, an age, a rank, and a research specialty.
  • Projects have a project number, a sponsor name (e.g., NSF), a starting date, an ending date, and a budget.
  • Graduate students have an SSN, a name, an age, and a degree program (e.g., M.S. or Ph.D.).
  • Each project is managed by one professor (known as the project’s principal investigator). Each project is worked on by one or more professors (known as the project’s co-investigators).
  • Professors can manage and/or work on multiple projects.
  • Each project is worked on by one or more graduate students (known as the project’s research assistants).
  • When graduate students work on a project, a professor must supervise their work on the project. Graduate students can work on multiple projects, in which case they will have a (potentially different) supervisor for each one.
  • Departments have a department number, a department name, and a main office.
  • Departments have a professor (known as the chairman) who runs the department.
  • Professors work in one or more departments, and for each department that they work in, a time percentage is associated with their job.
  • Graduate students have one major department in which they are working on their degree.
  • Each graduate student has another, more senior graduate student (known as a student advisor) who advises him or her on what courses to take.

Design and draw an ER diagram that captures the information about the university. Use only the basic ER model here; that is, entities, relationships, and attributes. Be sure to indicate any key and participation constraints.

Problem 4

A company database needs to store information about employees (identified by ssn, with salary and phone as attributes), departments (identified by dno, with dname and budget as attributes), and children of employees (with name and age as attributes). Employees work in departments; each department is managed by an employee; a child must be identified uniquely by name when the parent (who is an employee; assume that only one parent works for the company) is known. We are not interested in information about a child once the parent leaves the company.

Draw an ER diagram that captures this information

Problem 5

Notown Records has decided to store information about musicians who perform on its albums (as well as other company data) in a database. The company has wisely chosen to hire you as a database designer (at your usual consulting fee of $2500/day).

  • Each musician that records at Notown has an SSN, a name, an address, and a phone number. Poorly paid musicians often share the same address, and no address has more than one phone.
  • Each instrument used in songs recorded at Notown has a unique identification number, a name (e.g., guitar, synthesizer, flute) and a musical key (e.g., C, B-flat, E-flat).
  • Each album recorded on the Notown label has a unique identification number, a title, a copyright date, a format (e.g., CD or MC).
  • Each song recorded at Notown has a title and an author.
  • Each musician may play several instruments, and a given instrument may be played by several musicians.
  • Each album has a number of songs on it, but no song may appear on more than one album.
  • Each song is performed by one or more musicians, and a musician may perform a number of songs.
  • Each album has exactly one musician who acts as its producer. A musician may produce several albums, of course.

Design a conceptual schema for Notown and draw an ER diagram for your schema. The preceding information describes the situation that the Notown database must model. Be sure to indicate all key and cardinality constraints and any assumptions you make. Identify any constraints you are unable to capture in the ER diagram and briefly explain why you could not express them.

Problem 6

Computer Sciences Department frequent fliers have been complaining to Dane County Airport officials about the poor organization at the airport. As a result, the officials decided that all information related to the airport should be organized using a DBMS, and you have been hired to design the database. Your first task is to organize the information about all the airplanes stationed and maintained at the airport. The relevant information is as follows:

  • Every airplane has a registration number, and each airplane is of a specific model.
  • The airport accommodates a number of airplane models, and each model is identified by a model number (e.g., DC-10) and has a capacity and a weight.
  • A number of technicians work at the airport. You need to store the name, SSN, address, phone number, and salary of each technician.
  • Each technician is an expert on one or more plane model(s), and his or her expertise may overlap with that of other technicians. This information about technicians must also be recorded.
  • Traffic controllers must have an annual medical examination. For each traffic controller, you must store the date of the most recent exam.
  • All airport employees (including technicians) belong to a union. You must store the union membership number of each employee. You can assume that each employee is uniquely identified by a social security number.
  • The airport has a number of tests that are used periodically to ensure that airplanes are still airworthy. Each test has a Federal Aviation Administration (FAA) test number, a name, and a maximum possible score.
  • The FAA requires the airport to keep track of each time a given airplane is tested by a given technician using a given test. For each testing event, the information needed is the date, the number of hours the technician spent doing the test, and the score the airplane received on the test.

(a). Draw an Er Diagram for the Airport Database. Be Sure to Indicate the Various Attributes of Each Entity and Relationship Set; also Specify the Key and Participation Constraints for Each Relationship Set. Specify Any Necessary Overlap and Covering Constraints as well (in English)

(b). The Faa Passes a Regulation that Tests on a Plane Must Be Conducted by a Technician Who is an Expert on that Model. how Would You Express This Constraint in the Er Diagram? if You Cannot Express It, Explain Briefly

You can only express it if there is a fixed number of tests and models / specializations but as the diagram is represented currently it's not possible.

Problem 7

The Prescriptions-RX chain of pharmacies has offered to give you a free lifetime supply of medicine if you design its database. Given the rising cost of health care, you agree. Here’s the information that you gather:

  • Patients are identified by an SSN, and their names, addresses, and ages must be recorded.
  • Doctors are identified by an SSN. For each doctor, the name, specialty, and years of experience must be recorded.
  • Each pharmaceutical company is identified by name and has a phone number.
  • For each drug, the trade name and formula must be recorded. Each drug is sold by a given pharmaceutical company, and the trade name identifies a drug uniquely from among the products of that company. If a pharmaceutical company is deleted, you need not keep track of its products any longer.
  • Each pharmacy has a name, address, and phone number.
  • Every patient has a primary physician. Every doctor has at least one patient.
  • Each pharmacy sells several drugs and has a price for each. A drug could be sold at several pharmacies, and the price could vary from one pharmacy to another.
  • Doctors prescribe drugs for patients. A doctor could prescribe one or more drugs for several patients, and a patient could obtain prescriptions from several doctors.
  • Each prescription has a date and a quantity associated with it. You can assume that, if a doctor prescribes the same drug for the same patient more than once, only the last such prescription needs to be stored.
  • Pharmaceutical companies have long-term contracts with pharmacies. A pharmaceutical company can contract with several pharmacies, and a pharmacy can contract with several pharmaceutical companies. For each contract, you have to store a start date, an end date, and the text of the contract.
  • Pharmacies appoint a supervisor for each contract. There must always be a supervisor for each contract, but the contract supervisor can change over the lifetime of the contract.

(a). Draw an Er Diagram that Captures the Preceding Information. Identify Any Constraints not Captured by the Er Diagram

(b). How Would Your Design Change if Each Drug Must Be Sold at a Fixed Price by All Pharmacies?

Price would be incorporated into the Drug entity instead of the sells relationship.

(c). How Would Your Design Change if the Design Requirements Change as Follows: if a Doctor Prescribes the Same Drug for the Same Patient More than Once, Several such Prescriptions May Have to Be Stored

Prescriptions would need to become their own identifiable entity which includes some unique identifier.