Data Model and ER Diagram Questions
Data Model and ER Diagram Questions
CLASS EXERCISE
Design a conceptual, a logical and a physical data model for the following scenarios. Specify key attributes of each
entity type and structural constraints on each relationship type. Note any unspecified requirements, and make
appropriate assumptions to make the specification complete. Additionally, specify the data structures, data types etc.
using a database technology of your choice.
1. The COMPANY database keeps track of a company’s employees, departments, and projects. Suppose that, after the
requirements collection and analysis phase, the database designers stated the following description of the
company to be represented in the database:
a. The company is organized into departments. Each department has a unique name, a unique number, and a
particular employee who manages the department. We keep track of the start date when that employee began
managing the department. A department may have several locations.
b. A department controls a number of projects, each of which has a unique name, a unique number, and a single
location.
c. We store each employee’s name, NRC number, address, salary, gender, and birth date. An employee is
assigned to one department but may work on several projects, which are not necessarily controlled by the
same department. We keep track of the number of hours per week that an employee works on each project.
We also keep track of the direct supervisor of each employee.
d. We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent’s
first name, gender, birth date, and relationship to the employee.
2. Consider the following set of requirements for a university database that is used to keep track of students’
transcripts.
a. The university keeps track of each student’s name, student number, NRC number, current address and phone,
phone, birthdate, gender, class, and department name. Both NRC number and student number have unique values
for each student.
b. Each department is described by a name, department code, office number, office phone, and college. Both
name and code have unique values for each department.
c. Each course has a course name, description, course number, number of semester hours, level, and offering
department. The value of course number is unique for each course.
d. Each section has an instructor, semester, year, course, and section number. The section number distinguishes
sections of the same course that are taught during the same semester/year; its values are 1, 2, 3, . . ., up to the
number of sections taught during each semester.
e. A grade report has a studentnumber, section, letter grade, and numeric grade (0, 1, 2, 3, or 4).
3. A manufacturing company produces products. The following product information is stored: product name,
product ID and quantity on hand. These products are made up of many components. Each component can be
supplied by one or more suppliers. The following component information is kept: component ID, name,
description, suppliers who supply them, and products in which they are used. The Supplier information kept is
Supplier ID, Supplier Name, contact number, location and the products supplied by the supplier.
Entity-Relationship diagrams
1. Consider the following scenario:
A school is looking at creating a database to keep their information safe and in one place. This
school has pupils of which their names, PID, address, guardian’s names and name of grade are
kept. Pupils are assigned to a particular grade of which the name of grade, teacher_ID, room_No,
are kept. Teacher_ID, name, gender, qualification and date of birth are needed about teachers. A
teacher can only teach one grade at any given time. The headmaster has a name, ID and
qualification. All teachers report to the headmaster. All pupils must participate in at least one sport
in order to help them keep physically fit. Name, PID, trainer and teacher_ID is data kept about
sports. The school has a school bus which takes some pupils to and from home to school. Model,
PID, reg_No, driver and route are some of the information needed about the bus. The headmaster
oversees the overall management and running of all school activities (teachers, pupils, sports, etc).
a) Create an entity relationship diagram from the above information, clearly showing the
cardinalities and ordinalities.
A hospital in a certain city has started receiving more patients everyday due the increase in
population in the area. Due to this, they have decided to create a database. The hospital has doctors
who are identified by their DocID, Dname, speciality, Pnumber and university_attended. Age,
Pname, Pnumber, DocID, testID, wardNo and address are kept about patients. A doctor sees many
patients while working within his/her shift, which is identified by time, DocID and supervisor. All
patients have to undergo tests which are identified by testID, nurseID and type. Patients are
sometimes admitted in wards of which the wardNo, Wname, number_of_beds and nurse_on_duty
are kept. Nurses are always on hand to help with smooth running of the hospital by working in
different shifts. Nurses may carry out tests which are done in the laboratory and sometimes work
in the wards. Name, nurseID, wardNo, testID and time are kept about nurses. There are many
laboratories at the hospital that are identified by labNo, nurseID and type. Doctors may oversee
the overall running of the laboratories.
a) Draw an entity relationship diagram for the information above clearly showing the
cardinalities and ordinalities.