ER-EER Modeling- Practice Problems_Sol
ER-EER Modeling- Practice Problems_Sol
Problem 1
Draw an ER schema diagram for geography. It should contain the following kinds of entities together
with the listed attributes:
• Countries : Name, Area, Population, GDP ("Gross Domestic Product")
• Cities : Name , Population , Longitude , Latitude
• Rivers : Name , Length
• Seas : Name , Max depths
Name
M N
River Crosses Country
Ends
1
N 1
Ends Belongs to
1 N
Sea City
MaxDepths
(a) The university keeps track of each student's name, student number, social
security number, current address and phone, permanent address and phone,
birthdate, sex, class (freshman, sophomore, ..., graduate), major department,
minor department (if any), and degree program (B.A., B.S., ..., Ph.D.). Some user
applications need to refer to the city, state, and zip of the student's permanent
address, and to the student's last name. Both social security 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 different 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 student, section, letter grade, and numeric grade (0, 1, 2, 3,
4 for F, D, C, B, A, respectively).
Design an ER schema for this application, and draw an ER diagram for that schema.
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.
Problem 5
The company you work for wants to digitize their time cards. You have been asked to design the
database for submitting and approving time cards. Draw the database ER diagram with the following
information:
Make sure that you indicate all cardinality constraints and your model should not contain redundant
entity sets, relationships, or attributes. If you need to make any assumptions, include them in your
answer.
Problem 6
For the following problem, define an ERD for the initial requirements and then revise the ERD for the
new requirements. Your solution should have an initial ERD, and a revised ERD. Design a database to
assist physical plant personnel in managing assignments of keys to employees. The primary purpose
of the database is to ensure proper accounting for all keys.
• An employee has a unique employee number, a name, a position, and office number.
• A building has a unique building number, a name, and a location within the campus.
• A room has a room number, a size (physical dimensions), a capacity, a number of entrances, and a
description of equipment in the room. Because each room is located in exactly one building, the
identification of a room depends on the identification of a building.
• Key types (also known as master keys) are designed to open one or more rooms. A room may
have one or more key types that open it. A key type has a unique key type number, a date
designed, and the employee authorizing the key type. A key type must be authorized before it is
created.
• A copy of a key type is known as a key. Keys are assigned to employees. Each key is assigned to
exactly one employee, but an employee can hold multiple keys. The key type number plus a copy
number uniquely identify a key. The date the copy was made should be recorded in the database.
After reviewing your initial design, the physical plant supervisor decides to revise the requirements.
Make a separate ERD to show your refinements. Refine your original ERD to support the following
new requirements:
• The physical plant needs to know not only the current holder of a key but the past holders of a
key. For past key holders, the date range that a key was held should be recorded.
• The physical plant needs to know the current status of each key: in use by an employee, in
storage, or reported lost. If lost, the date reported lost should be stored.
building key
bldgno copyno
bldgname datemade
issuedto
location 1
employee
empno
contains empname
copyof position
OfficeNo 2
room
keytype
roomno authorizes
size opens keytypeno
numdoors dateassigned
equipment purpose
key
building keyhistory
copyno
bldgno datemade begdate
bldgname status usedby enddate
location datelost
contains useskey
copyof
room employee
keytype
roomno empno
size opens keytypeno empname
authorizes
numdoors dateassigned position
equipment purpose OfficeNo
Problem 7
We wat to draw an EER diagram for a small private airport database that is used to keep track of
airplanes, their owners, airport employees and pilots. From the requirements for this database, the
following information was collected. Each airplane has a registration number [Reg#], is of a particular
plane type [OF- TYPE], and is stored in a particular hangar [STORED-IN]. Each plane type has a model
number [Model}, a capacity [Capacity], and a location [Location]. The database also keeps track of the
owners of each plane [OWNS]and the employees who have maintained the plane [MAINTAIN]. Each
relationship instance in OWNS relates an airplane to an owner and includes the purchase data [Pdate].
Each relationship instance in MAINTAIN relates an employee to a service record [SERVICE]. Each plane
undergoes service many times; hence, it is related by [PLANE-SERVICE] to a number of service records.
A service record includes as attributes the date of maintenance [Date], the number of hours spent on
the work [Hours], and the type of work done [Workcode]. We use a weak entity type [SERVICE] to
represent airplane service, because the airplane registration number is used to identify a serVice
record. An owner is either a person or a corporation. Hence, we use a union category [OWNER] that is
a subset of the union of corporation [CORPORATION] and person [PERSON] entity types. Both pilots
[PILOT] and employees [EMPLOYEE] are subclasses of PERSON. Each pilot has specific attributes license
number [Lic-Num] and restrictions[Restr]; each employee has specific attributes salary [Salary] and
shift worked [Shift]. All person entities in the database have data kept on their social security number
[Ssn], name [Name], address[Address], and telephone number [Phone}.For corporation entities, the
data kept includes name [Name}, address[Address], and telephone number [Phone}. The database also
keeps track of the types of planes each pilot is authorized to fly [FLIES] and the types of planes each
employee can do maintenance work on [WORKS-ON].
Problem 8
A library service wants to create a database to store details of its libraries, books and borrowers. Details
include the following:
A book has a unique ISBN number, a title and one or more authors. The library service may own several
copies of a given book, each of which is located in one of the service’s libraries. A given library contains
many books, and in order to distinguish different copies of the same book a library assigns a different
copy-number to each of its copies of a given book; the price that was paid for each copy is also
recorded. Every library has a unique name and is either a main library or a branch library. A main library
may have zero or more branch libraries and every branch library is a branch of exactly one main library.
A borrower has a name and a unique ID code. A borrower can have many books on loan, but each copy
of a book can only be on loan to one borrower. A borrower could borrow the same book on several
occasions, but it is assumed that each such loan will take place on a different date.
Draw an EER Model for above requirement.
title author
ISBN Book
m
1 m m 1
Borrower borrow Loan lend Copy
m
1
Library
no-of-branches d
Main Branch
1 m
branch
Problem 9
A taxi company needs to model their activities. There are two types of employees in the company:
drivers and operators. For drivers it is interesting to know the date of issue and type of the driving
license, and the date of issue of the taxi driver’s certificate. For all employees it is interesting to know
their personal number, address and the available phone numbers. The company owns a number of
cars. For each car there is a need to know its type, year of manufacturing, number of places in the car
and date of the last service. The company wants to have a record of car trips. A taxi may be picked on
a street or ordered through an operator who assigns the order to a certain driver and a car. Departure
and destination addresses together with times should also be recorded.