0% found this document useful (0 votes)
0 views

ER-EER Modeling- Practice Problems_Sol

The document outlines various practice problems related to ER/EER modeling for a database course at the National University of Computer and Emerging Sciences. It includes problems on designing ER diagrams for geographical entities, U.S. House of Representatives voting information, university student transcripts, time card management, key management for physical plant personnel, and a private airport database. Each problem requires creating ER diagrams while stating assumptions and key attributes for the entities involved.

Uploaded by

tfaizanvr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

ER-EER Modeling- Practice Problems_Sol

The document outlines various practice problems related to ER/EER modeling for a database course at the National University of Computer and Emerging Sciences. It includes problems on designing ER diagrams for geographical entities, U.S. House of Representatives voting information, university student transcripts, time card management, key management for physical plant personnel, and a private airport database. Each problem requires creating ER diagrams while stating assumptions and key attributes for the entities involved.

Uploaded by

tfaizanvr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

National University of Computer and Emerging Sciences, Lahore Campus

Course: Database Systems Course Code: CS2005


Program: BS(Computer Science)
Instructor: Muhammad Ishaq Raza

Practice Problem: ER/EER Modeling - Solution

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

Model the following relationships between the geographical entities:


• Each city belongs to exactly one country
• Each river crosses one or several countries
• Each river ends in another river or in a sea

State any assumptions you make about the additional requirements.


Length Name Area Population GDP

Name

M N
River Crosses Country
Ends
1

N 1

Ends Belongs to

1 N

Sea City

MaxDepths

Name Name Population Longitude Latitude


Problem 2
Design an ER schema for keeping track of information about votes taken in the U.S. House of
Representatives during the current two-year congressional session. The database needs to keep track
of each U.S. STATE’s Name (e.g. Texas, New York, California) and include the Region of the state
(whose domain is {Northeast, Midwest, Southeast, Southwest, West}). Each CONGRESSPERSON in the
House of Representatives is described by his or her Name, plus the District represented, the StartDate
when the congressperson was first elected, and the political Party to which he or she belongs (whose
domain is {Republican, Democrat, Independent, Other}). The database keeps track of each BILL (i.e.
proposed law), including the BillName, the DateOfVote on the bill, whether the bill PassedOrFailed
(whose domain is {Yes, No}), and the Sponsor (the congressperson(s) who sponsored—that is,
proposed—the bill). The database keeps track of how each congressperson voted on each bill
(domain of vote attribute is {Yes, No, Abstain, Absent}). Draw an ER schema diagram for this
application. State clearly any assumptions you make.
Problem 3
Draw an ER diagram for the following case study. Your diagram should indicate the keys of all entities,
as well as the cardinality and participation constraints of all relationships. Note any unspecified
requirements, and make appropriate assumptions to make the specification complete but clearly
state your assumptions along the diagram.
The database supports the placement office of a leading graduate school of computing. The primary
purpose of the database is to schedule interviews and facilitate searches by students and companies.
Consider the following requirements:
• Student data include a unique student identifier, a name, a phone number, an email address, a
major, a minor, and a GPA.
• The placement office maintains a standard list of positions based on the Labor Department’s list of
occupations. Position data include a unique position identifier and a position description.
• Company data include a unique company identifier, a company name, and a list of positions and
interviewers. Each company must map its positions into the position list maintained by the
placement office. For each available position, the company lists the cities in which positions are
available.
• Interviewer data include a unique interviewer identifier, a name, a phone, an email address, and a
web address. Each interviewer works for one company.
• An interview includes a unique interview identifier, a date, a time, a location (building and room),
an interviewer, and a student.
position
student posid
stdid interview name
name interviewid
phone attends date
email 1 time available
web bldgname
major roomno
minor roomtype comppos
gpa city
adviserno state
advisername
conducts
offers
interviewer
interviewerid company
name
worksfor compid
phone
compname
email
Problem 4
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, 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:

• A timecard should have hours worked and date submitted


• Each timecard is associated with exactly one employee. An employee can be permanent or
employed on hourly basis.
• Each timecard should have a unique id
• Each timecard has a status: it is either approved, not approved, or pending
• Each employee has a unique id, name and address.
• Each employee submits a time card every pay period. i.e. In 1 year, they will submit multiple
time cards
• Each employee either has direct deposit or physical check as their method of payment
• Each employee is associated with exactly one manager
• Each manager has a unique id and a name
• Each manager is in charge of multiple employees
• Each manager approves time cards for multiple employees

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

name ID date price copy

m
1 m m 1
Borrower borrow Loan lend Copy
m

name number location

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.

You might also like