Erd Tutorial
Erd Tutorial
ERD EXERCISES
1. Draw an ERD for the following specification.
There are many employees working at Century 2000 Company. Some employees are workers,
some are engineers and the others are clerks. Clerks have a monthly salary. Engineers have a
montly salary and a specialization, workers have hoursWorked and hourlywage as a special
attributes.Each employee works at a given department. For each department you need to store
uniqueid and name. In addition to this some employees are superviors of other employees of the
same type. Engineers are assigned to projects. Projects are done for customers. On each project you
may have engineers and many workers participating. You need to keep track of the number of
hours each worker spend on each project. Workers also deal with repairs. A repair involves a
description , timeReported and an urgencyCode.
2. For each building you need to store unique building no and name. More than one staff is working
in each building, and each staff can work in many buildings. For each staff you need to store
unique staff no, first name, last name, date of birth and a city. In each building there is only one
elevator. For each elevator you need to store unique elevator no and capacity. There are Mechanics
who fix elevators. Each mechanic can fix many elevators, and each elevator can be fixed by many
mechanics. For each mechanic you need to store unique mechanic id, ssno (social security
number), a name, a city, and a date of birth. One of the mechanics is the supervisor of the other
mechanics. Each mechanic has many dependents. (i.e. wife, children, mother, father). For each
dependent need to store dependent no and name. The dependent is identified by the combination of
dependent no and mechanic id.
3. The company organizes many different types of parties for its customers. For all parties, the
company assigns a unique id, a party date, start time, finish time and duration. Duration is
calculated as the number of hours between start-time and finish-time. Each party is hosted (owned)
by exactly one customer. A customer may host many parties. Each customer has a name, an
address, a phone number and a unique id. There are many employees working at the company.
Each employee has a name, salary and a unique id. A number of meetings are arranged for each
party during the organization. Each meeting belongs to exactly one party. For each meeting a
meeting date, a comment and a meeting number is recorded. Each meeting is identified by using
the meeting number and party id together. Each meeting may contain one or more employees. An
employee may be included in zero or more meetings.
5. Each train is identified by a train_no and also has a unique name. Each train is used on two routes
but there may be many trains assigned to each route. Each route is identified by a route_no. Each
route also has a source_city and a destination_city. Each route has a number of stops that are
stations on the route. For each station you need to store a station_no, a city and a capacity. There
may be many routes that stop at a given station and a route may stop at many stations. For each
route and station that the route stops at, there is a unique stop_no. Many employees work on each
train. Each employee is identified by an employee_no. Each employee has a name and a salary.
There are many different type of employees working on trains. Waiters are employees who have a
special attribute tips. Mechanics are also employees who have two special attributes: blood_type
and specialty. Each mechanic has a supervisor who is also a mechanic. A mechanic may supervise
many other mechanics.
4. A company called Special Training Center (STC) specializes on IT training. At STC there are only
two types of person. They are Trainees and Instructors. For each person you need to keep name,
address, phone and unique person id. Additionally you need to keep track of unique trainee id and
date_of_birth for each trainee. For each instructor specialty should be kept as an additional
attribute.
STC Company provides many courses for its trainees. For each course you need to store unique
course code and a title. There are number of Course Sessions for each course. For each course
session, keep session number, day and time attributes. In each course session, session number is
unique within a Course. Each trainee registers for a minimum of 1 and a maximum of 3 course
sessions. The number of trainees that can register for a course session is limited with 35. Each
course session is assigned to a maximum number of 5 instructors. A course session may be
assigned to no instructors, if there are no trainees registered for it. An instructor may be assigned to
a maximum of 10 course sessions. Each course is organized in minimum 3 and maximum 15
course sessions. A course session belongs to one and only one of the courses.
One of the instructors is the head of all other instructors in the STC Company. A person can be
both instructor and trainee in the company. But the instructor cannot be the trainee for the course
that he/she is assigning.
6. 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. 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 phone has more than
one phone. Each instrument used in songs recorded at Notown has 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
title, a copyright date, a format (e.g., CD or MC), and an album identifier. 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.
7. A company needs to store information about employees (identified by ssno, 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; child must be identified uniquely by name when 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.
8. Design an E/R diagram for the following situation: We wish to model crimes and punishments.
Crimes have a name and a degree (e.g., "murder in the first degree"); together, they form a key.
Punishments have unique id. A crime is either a felony (e.g., murder, sabotage) or a
misdemeanor (e.g., swearing, violating any traffic rule) Punishments are either fines or jail
sentences. A fine has an associated amount, and a jail sentence has a minimum and a maximum
number of years. The punishment for a misdemeanor is always a fine. The punishment for a
felony can be either a jail sentence, a fine, or both.
9. Draw an ER diagram for the EMU Slimming Center based on the specification given below.
There are many dietitians in the center. An identity number identifies each dietitian. For each
dietitian, you need to store a name, a date of birth and one or more phone numbers. There are also
many clients in the center. The following are properties of a client: a unique id, a name, a date of
birth, a start_weight, an end_weight, and number_of_kilos. (Please notice that number_of_kilos=
start_weight end_weight). A dietitian gives a menu to a client every week. Many diet menus are
available. Each diet menu has a unique name. There are many food categories. Each food category
has a unique name a brief description. There are at least 3 food categories in each diet menu and a
food category appears on many diet menus. The amount of each food category in each menu must
be stored in the database. Each picture has a picture number and image content. A picture is
identified by client id and picture number.