Você está na página 1de 7

Rutgers University, Business School/Undergraduate New Brunswick

Operations Management (33:136:370)


Instructor: Jonathan Eckstein

Practice Material from Prior Midterm Exams


The format of the exam will be as follows (point totals are approximate and subject to change):
(30 points) Query exercises (on paper)
(40 points) One database design problem
(30 points) One database normalization problem
Since the last exam, we have covered many-to-many relationships, as well as multiple
relationships between the same pair of tables you should expect to see at least one of these
features on the exam. This handout consists of one sample question for the query exercises,
three sample questions for database design, and two sample questions for normalization.
Q1. Query exercises
Part of the database in the local public librarys information system has the following form:
AUTHOR(AuthorID, Name, Nationality, BirthYear, DeathYear)
BOOK(ISBN, Title, YearPublished, NumPages, Edition, Category, Language, Publisher)
WROTE(AuthorID, ISBN, AuthorPosition)
AuthorID foreign key to AUTHOR
ISBN foreign key to BOOK
COPYOFBOOK(BarCode, ISBN, DateAcquired)
ISBN foreign key to BOOK
The library may have more than one copy of the most popular books, each with a different bar
code, but the same ISBN. DeathYear is blank for authors who are still alive. YearPublished,
BirthYear, and DeathYear are integer fields that hold only a year, not a more detailed date. The
WROTE table allows the database to handle books having multiple authors, and its
AuthorPosition attribute is an integer which indicates the order in which each author appears on
the books title page. For example, if the book with ISBN 00-783-986392 has the authors Karl
Studden (AuthorID 59201), Andras Borovik (AuthorID 27133), and William Cooke (AuthorID
30332), listed in that order, then WROTE would contain the records:
AuthorID
ISBN
AuthorPosition
59201
00-783-986392
1
27133
00-783-986392
2
30332
00-783-986392
3
YearPublished is stored an integer, much like BirthYear and DeathYear, while DateAcquired
used an Access-style date/time datatype. NumPages is stored as an integer, and all other fields
have the text datatype.

Practice Material for Second Midterm Exam

-- 1 --

Write the standard SQL code needed implement the following queries. Each querys columns
output should appear in the order specified in the question.
(a) Show the title, category, and publication year of all Spanish-language books
published in or after the year 2002.
(b) Show the title, name of first author, publication year, and number of pages for all
books with at least 1000 pages. List them in order of number of pages, longest
books first.
(c) Produce a table that shows the title of each book in the library and the number of
copies of it the library owns. Books with different ISBNs but the same title should
be treated as different books.
(d) Show the title, year of publication, and number of pages for all books whose
category is fiction and have more than one author.
(e) Show the names of authors whose nationality is "USA", along with the number of
books for which they are the first author and that were published either before
1939 or after 1945, and the average number of pages for such books. Authors who
did not write any such books need not appear in the output.
Q2. Database design: the Jersey Pacific Railroad
The Jersey Pacific Railroad (JPRR) needs a database to track the past and present movement of
locomotives, freight cars, and freight. (Note: this problem is a simplification of a real railroad.)
A terminal is a place where a train may begin or end its journey, and is known by a unique
four-letter code. For each terminal, the system should also store a name, description, GPS
latitude, GPS longitude, and feet of available track storage space.
Each train ever operated by the JPRR has a unique ID number and travels from a single origin
terminal to a single destination terminal. The system should record the origin and destination
of each train, the departure date and time, and the arrival date and time.
Each train carries one or more shipments. For each shipment, the system should record an ID
number, a description of the freight involved (examples: gravel, scrap metal, wheat, or empty),
a total weight, a total volume, and a negotiated price. Each shipment is also associated with a
single customer; for each customer, the system should store a name, billing address, city, state,
and zip code, along with a phone number. Assume the JPRR does not have a zip code table. For
simplicity, assume that each shipment is part of only one train (and thus has the same origin and
destination as that train).
Each shipment uses one or more freight cars. On a given train, a single freight car is never
split between two shipments; it always carries goods from just one shipment. However, once a
train has arrived at its destination, each of its freight cars of course becomes free to be part of a
different shipment on a different train. The system should track which freight cars are in each
shipment. For each freight car, the system should store a unique registration number, a type

Practice Material for Second Midterm Exam

-- 2 --

(boxcar, hopper car, tank car, etc.), empty weight in tons, cargo capacity in tons, length in feet,
and date built.
Finally, each train is hauled by one or more locomotives. Each locomotive in the JPRRs fleet
has a unique placard number. In addition to this number, the system should store the
locomotives manufacturer, model, horsepower, weight in tons, and year built. The system
should be able to record which locomotives hauled each train. Once a locomotive has finished
with one train, it of course becomes free to haul a different train.
Design the database required for the JPRRs system. Draw an entity-relationship diagram
and write a database design outline. You may create ID fields where necessary.
Q3. Database Design: Software Experts, Inc.
You work for Software Experts, Inc (SEI), a firm providing highly skilled software experts to
customers for a variety of software development and consulting projects, billed on an hourly
basis. For each customer, SEI wants its information system to store the company name, street
address, city, state, zip code, and phone number. Assume SEI does not have a zip code table.
Each customer has one or more projects with SEI (but each project is only for one customer).
For each project past and present, you want to store a name, start date, end date (blank for
projects that are still ongoing), and hourly billing rate. For each project, you also want to store
what kinds of software it relates to: for example, one project might relate to Linux, Oracle,
Apache (a kind of web server software), and PHP. Another project might relate to
Microsoft Windows, Microsoft .NET, and Oracle. You have a long and constantly
growing list of the kinds of software that can be involved in the projects you work on.
For each of the experts SEI employs, you want to store a first name, last name, office number,
phone extension, cell phone number, and e-mail address. For each employee, you also want your
information system to store the kinds of software in which he or she has expertise. For example,
a particular employee might have expertise in Oracle, Access, and DB2 (the possibilities
here are drawn from the same list of kinds of software as in the previous paragraph).
Whenever one of your experts spends time working on a particular project, you want to record
which expert was involved, which project, the date and time work started, and the date and time
work ended. Each expert is considered to be working on at most one project at any given instant
in time. The hourly rate charged to the customer for each project is negotiated at the project
outset, and is the same for the entire duration of the project and for all experts working on it.
Design the database required for SEI to store the above information. Draw an entityrelationship diagram and write a database design outline. You may create ID fields
where necessary.
Q4. Database Design: Clearview Solar Engineering
Clearview Solar Engineering, Inc. manages solar and alternative energy projects for a large
number of corporate, governmental, and institutional clients. It employs a rapidly expanding
team of engineers (currently numbering about 60). You have been charged with constructing a
Practice Material for Second Midterm Exam

-- 3 --

database to help track the firms growing portfolio of projects, engineers, technology teams, and
customers. Assume for the purposes of this question that you do not have access to a zip-code
table.
The main unit of work at Clearview is the project. Each project has a name, a description, a
project contact name, project contact phone number, and project contact e-mail. It also has a
worksite address (street address, city, state, and zip code). Each project is performed for single
customer; for each customer you want to store a name, billing address (also street address, city,
state, and zip code), and master phone number. It is common for a single customer to engage
Clearviews services for multiple projects, and for a projects worksite address to differ from its
customers billing address.
When it sets up a project, Clearview and the customer negotiate the projects payment schedule,
which often consists of multiple payments. Each payment has a description (typically a specific
project milestone that must be reached), an expected date, a payment amount, and an actual
payment date. The actual payment date should be left blank for payments not yet made.
For each of Clearviews engineers, you want the database to store a first name, middle initial,
last name, highest degree earned, date degree awarded, office number, phone extension, mobile
phone number, and e-mail address. Each project is assigned to a single primary engineer, who
is responsible for its progress and the quality of work done. Each project is also assigned a
single backup engineer to handle pressing issues if the primary engineer is not available.
Finally, Clearview maintains dozens of technology teams to track the latest developments in
alternative energy technology. For each of these teams, you want to store a name, a description,
and the date the team was formed. You also wish to keep track of which engineers are on which
teams. Most teams have 4-5 members, but some are larger, and a single engineer may be on
more than one team.
Design the database required to store the information described above. Draw an entityrelationship diagram and write a database design outline. You may create ID fields
where necessary.
Q5. Normalization: Election Results
The table on the next page has the form
VOTECOUNT(Mun#, Municipality, Ward, Can#, Candidate, Off#, Office, Par#, Party, Votes).
The data displayed on the last page represent a portion of Huxtable countys tally of votes in the
November 2008 election. A ward is a particular voting district and polling place within a
municipality (town or city). By way of example,

The Obama/Biden ticket (candidate #1) was the Democratic party (party #1) candidate
for president/vice president (office #1). It received 471 votes in Huxville ward 1, 307
votes in Huxville ward 2, and 213 votes in Bracketown ward 1.

Practice Material for Second Midterm Exam

-- 4 --

Mun#
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2

Amanda Wright (candidate #6) was the Republican party (party #2) candidate for the
U.S. House 12th district (office #2). She receive 356 votes in Huxville ward 1, 491 votes
in Huxville ward 2, and 212 votes in Bracketown ward 1.
Municipality
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Huxville
Bracketown
Bracketown
Bracketown
Bracketown
Bracketown
Bracketown
Bracketown
Bracketown
Bracketown
Bracketown

Ward
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1

Can#
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
10
11
12

Candidate
Obama/Biden
McCain/Palin
Clemente/McKinney
Nader/Gonzalez
William Hauzer
Amada Wright
Otis Farmer
William Locale
Federico Martinez
Obama/Biden
McCain/Palin
Clemente/McKinney
Nader/Gonzalez
William Hauzer
Amada Wright
Otis Farmer
William Locale
Federico Martinez
Obama/Biden
McCain/Palin
Clemente/McKinney
Nader/Gonzalez
William Hauzer
Amada Wright
Otis Farmer
Buster Brackett
Amy Kotsoumas
Frank Wilde

Off#
1
1
1
1
2
2
2
3
3
1
1
1
1
2
2
2
3
3
1
1
1
1
2
2
2
4
4
4

Office
President/Vice President
President/Vice President
President/Vice President
President/Vice President
US House 12th district
US House 12th district
US House 12th district
Huxville City Council
Huxville City Council
President/Vice President
President/Vice President
President/Vice President
President/Vice President
US House 12th district
US House 12th district
US House 12th district
Huxville City Council
Huxville City Council
President/Vice President
President/Vice President
President/Vice President
President/Vice President
US House 12th district
US House 12th district
US House 12th district
Bracketown Freeholder
Bracketown Freeholder
Bracketown Freeholder

Par#
1
2
3
4
1
2
3
1
2
1
2
3
4
1
2
3
1
2
1
2
3
4
1
2
3
1
2
4

Party
Democratic
Republican
Green
Independent
Democratic
Republican
Green
Democratic
Republican
Democratic
Republican
Green
Independent
Democratic
Republican
Green
Democratic
Republican
Democratic
Republican
Green
Independent
Democratic
Republican
Green
Democratic
Republican
Independent

Votes
471
243
12
0
402
356
4
349
380
307
341
2
8
227
491
0
185
501
213
332
3
0
191
212
17
250
181
35

Each municipality/ward combination has its own ballot, containing only candidates valid for that
combination. The table contains a row for each valid ballot entry. In particular:
There are no rows for Huxville City Council candidates in Bracketown ward 1, since
Bracketown residents do not vote for Huxville city council.
If a candidate is on the ballot in a given municipality/ward combination, but has received
no votes there, the table contains a corresponding row, but it shows zero votes. For
example, the Nader/Gonzalez ticket was on the ballot but received no votes in Huxville
ward 1.
Assume each candidate can run for only one office at a time, and you only need to store
information for a single election.
(a) What is a possible primary key for the VOTECOUNT table? (Note: it may have to
be a composite key.)

Practice Material for Second Midterm Exam

-- 5 --

(b) Identify all the partial dependencies in the VOTECOUNT table. Also, identify all
the transitive dependencies in the table.
(c) Normalize the structure of VOTECOUNT, breaking it up into multiple tables, so the
resulting database is in third normal form. Draw an entity-relationship diagram
and write a design outline for the resulting database.

Q6. Database normalization: the Piscataway Stock Exchange


The table on the below shows part of the data stored by the Piscataway Stock Exchange (PSE).
The information in the first nine rows of table should be interpreted as follows:
Trans
ID
567823

567824

567825

DateAndTime
23-Aug-2006
9:37

CustID
789

Cust
Name
MegaBrokers

Trans
Type
Sell

Ticker
Symbol
TMAX

Stock
Name
TechMax

Num
Shares
1000

Unit
Price
$ 8.24

Categ
Code
SMC

Category
Descrip
Small Cap

23-Aug-2006
9:38

989

Kirt Kerorian

Buy

TMAX

TechMax

1000

$ 8.26

IT
SMC

Info Tech
Small Cap

$12.56

IT
LGC

Info Tech
Large Cap
Manufacturing
Europe
Mid Cap

23-Aug-2006
9:41

789

MegaBrokers

Sell

ALO

Alstom,
SA

2500

567826

23-Aug-2006
9:41

320

TradePartners

Sell

WFMI

Whole
Foods

700

$20.41

MAN
EUR
MDC

567827

23-Aug-2006
9:42

789

MegaBrokers

Buy

WFMI

Whole
Foods

500

$20.43

RET
MDC

Retail
Mid Cap

567828

23-Aug-2006
9:42

989

Kirt Kerorian

Buy

WFMI

Whole
Foods

200

$20.43

RET
MDC

Retail
Mid Cap

567829

23-Aug-2006
9:42

210

ElecTrade

Buy

ALO

Alstom,
SA

2500

$12.58

RET
LGC

Retail
Large Cap
Manufacturing
Europe
Large Cap

567830

23-Aug-2006
9:44

320

TradePartners

Sell

MSFT

Microsoft

4000

$43.82

MAN
EUR
LGC

567831

23-Aug-2006
9:44

776

Max Selmer

Sell

MSFT

Microsoft

1000

$43.82

IT
LGC

Info Tech
Large Cap

567832

23-Aug-2006
9:45

789

MegaBrokers

Buy

MSFT

Microsoft

5000

$43.84

IT
LGC

Info Tech
Large Cap

567833

23-Aug-2006
9:45

989

Kirt Kerorian

Sell

TM

Toyota

800

$51.00

IT
LGC

Info Tech
Large Cap

$51.02

MAN
AS
LGC

Manufacturing
Asia
Large Cap

MAN
AS

Manufacturing
Asia

567834

23-Aug-2006
9:46

776

Max Selmer

Buy

Practice Material for Second Midterm Exam

TM

Toyota

800

-- 6 --

At 9:37 AM on August 23, 2006, MegaBrokers sold 1000 shares of TechMax (ticker
symbol TMAX) for $8.24 per share. TechMax is categorized as a small cap (SMC) and
information technology (IT) stock.
One minute later, Kirt Kerorian bought this same block of shares for $8.26 per share.
At 9:41 AM, MegaBrokers sold another block of shares: 2500 shares of Alstom, SA,
which is categorized as large cap (LGC), manufacturing (MAN), and European (EUR).
The price was $12.56 per share.
Also at 9:41 AM, TradePartners sold 700 shares of Whole Foods Market (WFMI) at
$20.41 per share. Whole Foods is categorized as a mid cap (MDC) and retail (RET)
stock.

The rest of the table should be interpreted similarly. As suggested in the table, you should treat
the assignment of stocks to categories as essentially static: for instance, if TechMax is considered
a small cap and information technology stock during one transaction, it should be considered a
small cap and information technology stock for the purposes of any other transaction.
Design a third-normal-form database to store information like that shown in the table.
Draw an entity-relationship diagram and write a database design outline.

Q7. Normalization: Tire Pricing (30 points)


Consider the following TIREPRICE table used by a tire wholesaler. Some columns and many
rows have been omitted for brevity. Each type of tire is made in some subset of the possible
sizes, and the price of a tire depends on both its type and its size.
TireTypeID
109383
109383
109383
109383
108392
108392
108392
007653
007653
007653
208931
208931
208702
208702
208702
209993
092839
092839
092839
088394

ManufID
MICH
MICH
MICH
MICH
MICH
MICH
MICH
GRICH
GRICH
GRICH
GYEAR
GYEAR
GYEAR
GYEAR
GYEAR
GYEAR
FSTONE
FSTONE
FSTONE
FSTONE

Manufacturer
Michelin
Michelin
Michelin
Michelin
Michelin
Michelin
Michelin
B.F. Goodrich
B.F. Goodrich
B.F. Goodrich
Goodyear
Goodyear
Goodyear
Goodyear
Goodyear
Goodyear
Firestone
Firestone
Firestone
Firestone

TireTypeName
Energy Saver
Energy Saver
Energy Saver
Energy Saver
LTX A/S
LTX A/S
LTX A/S
Long Trail T/A
Long Trail T/A
Long Trail T/A
Viva 2
Viva 2
Assurance
Assurance
Assurance
Wrangler MT/R
FR710
FR710
FR710
Destination MT

SizeCode
P185/65R14
P185/65R15
P185/70R14
P195/60R15
P255/65R17
P255/65R18
P255/70R18
P255/75R17
P255/65R18
P255/70R18
P185/65R14
P185/65R15
P185/65R14
P185/65R15
P185/70R14
LT235/75R15C
P185/70R14
P185/70R15
P195/60R15
LT235/75R15C

SizeDescrip
Passenger
Passenger
Passenger
Passenger
Light Truck
Light Truck
Light Truck
Light Truck
Light Truck
Light Truck
Passenger
Passenger
Passenger
Passenger
Passenger
Off Road
Passenger
Passenger
Passenger
Off Road

Price
$112
$129
$112
$142
$208
$220
$229
$128
$137
$145
$ 66
$ 71
$ 91
$ 97
$ 95
$264
$102
$118
$130
$251

Normalize the structure of this table so that it becomes a database in third normal form.
Draw an entity-relationship diagram and write a design outline for the resulting database.

Practice Material for Second Midterm Exam

-- 7 --

Você também pode gostar