You are on page 1of 6

CENG315 INFORMATION MANAGEMENT

2016 FALL – MIDTERM - DEC. 5, 2016 - ANSWERS

STUDENT NAME AND NUMBER:


You Have 90 Minutes and Closed Book.

Q.1 (25 points) UPS prides itself on having up-to-date information on the processing and current
location of each shipped item. To do this, UPS relies on a company-wide information system. Shipped
items are the heart of the UPS product tracking information system. Shipped items can be characterized
by item number (unique), weight, dimensions, insurance amount, destination, and final delivery date.
Shipped items are received into the UPS system at a single retail centre. Retail centres are characterized
by their type, uniqueID, and address. Shipped items make their way to their destination via one or more
standard UPS transportation events (i.e., flights, truck deliveries). These transportation events are
characterized by a unique scheduleNumber, a type (e.g, flight, truck), and a deliveryRoute.
Please create an Entity Relationship diagram that captures this information about the UPS system. Be
certain to indicate identifiers and cardinality constraints.

Answer 1)

Q.2) (30 points) Production tracking is important in many manufacturing environments (e.g., the
pharmaceuticals industry, children’s toys, etc.). The following ER diagram captures important
information in the tracking of production. Specifically, the ER diagram captures relationships between
production lots (or batches), individual production units, and raw materials.

1
CENG315 INFORMATION MANAGEMENT
2016 FALL – MIDTERM - DEC. 5, 2016 - ANSWERS

STUDENT NAME AND NUMBER:


You Have 90 Minutes and Closed Book.

a) (15 points) Please convert the ER diagram into a relational database schema. Be certain to
indicate primary keys and referential integrity constraints, strong and weak entities if they are
exist etc..
Answer 2.a)
(5 points)

2
CENG315 INFORMATION MANAGEMENT
2016 FALL – MIDTERM - DEC. 5, 2016 - ANSWERS

STUDENT NAME AND NUMBER:


You Have 90 Minutes and Closed Book.

For grading:
 (3 points) Strong Entities – Production Units, Lot, Raw Materials: Has attributes, Has Primary
key defined.
 (2 points) One to Many Relationship – Lot Number as Foreign Key on Production Unit Entity:
Exists or not
 (2 points) Many to Many Relationship - Relation for Raw Material Usage: Relation exists, Has
primary key correctly identified, has additional attribute
 (3 points) Referential Integrity Constraints - There is a constraint between Production Units and
Lot; Lot has total participation and each production unit has to have at least one Lot tuple. Each
Lot has to have at least one Raw material in production process of Lot.

b) (10 points) The ER diagram/relational database schema contains several instances of data
redundancy. Please identify one instance where a data redundancy issue exists.
Answer 2.b) Examples include:
 Both production description and product type are being stored for each and every
production unit. The production description could be stored elsewhere.
 Production type and production description are being stored on each and every
production unit, when these parameters are most likely the same for the entire lot.
They could be stored on the Lot entity.
c) (5 points) The current ER diagram has the following relationship, “raw materials are used in 0 to
many lots.” Please explain, in the context of the manufacturing environment, how the meaning
changed if the minimal cardinality is changed to “1” (i.e., the relationship becomes "raw
materials are used in 1 to many lots.”)
Answer 2.c) The current representation of “raw materials are used in 0 to many lots” implies that raw
materials can be in the system without being designated for a specific lot. If the minimum cardinality was
changed to 1, this would imply that all raw materials must be designated as related to at least one lot.

Q.3) (20 points) Consider the following relations:


Doctor(SSN, FirstName, LastName, Specialty, YearsOfExperience, PhoneNum)
Patient(SSN, FirstName, LastName, Address, DOB, PrimaryDoctor_SSN)
Medicine(TradeName, UnitPrice, GenericFlag)
Prescription(Id, Date, Doctor_SSN, Patient_SSN)
Prescription_Medicine(Prescription Id, TradeName, NumOfUnits)

 The Doctor relation has attributes Social Security Number (SSN), first and last names, specialty,
the number of experience years, and the phone number.
 The Patient relation has attributes SSN, first and last names, address, date of birth (DOB), and
the SSN of the patient’s primary doctor.
 The Medicine relation has attributes trade name, unit price, and whether or not the medicine is
generic (True or False).
 The Prescription relation has attributes the prescription id, the date in which the prescription is
written, the SSN of the doctor who wrote the prescription, and the SSN of the patient to whom
the prescription is written.

3
CENG315 INFORMATION MANAGEMENT
2016 FALL – MIDTERM - DEC. 5, 2016 - ANSWERS

STUDENT NAME AND NUMBER:


You Have 90 Minutes and Closed Book.

 The Prescription_Medicine relation stores the medicines written in each prescription along with
their quantities (number of units).

Write the relational algebra expressions for the following queries


a) (5 points) List the trade name of generic medicine with unit price less than $50.

b) (5 points) List the first and last name of patients whose primary doctor named ʻJohn Smithʼ.

c) (10 points) List the SSN of patients who have ʻAspirinʼ and ʻVitaminʼ trade names in one
prescription.

𝑹𝟏 ← 𝚷
𝑰𝒅← 𝑷𝑴𝟏.𝑷𝒓𝒆𝒔𝒄𝒓𝒊𝒑𝒕𝒊𝒐𝒏.𝑰𝒅
(𝝈 𝑷𝑴𝟏.𝑷𝒓𝒆𝒔𝒄𝒓𝒊𝒑𝒕𝒊𝒐𝒏𝑰𝒅=𝑷𝑴𝟐.𝑷𝒓𝒆𝒔𝒄𝒓𝒊𝒑𝒕𝒊𝒐𝒏𝑰𝒅 𝑨𝑵𝑫 𝑷𝑴𝟏.𝑻𝒓𝒂𝒅𝒆𝑵𝒂𝒎𝒆=𝑷𝑴𝟐.𝑻𝒓𝒂𝒅𝒆𝑵𝒂𝒎𝒆
(𝝆𝑷𝑴𝟏 (𝑷𝒓𝒆𝒔𝒄𝒓𝒊𝒑𝒕𝒊𝒐𝒏𝑴𝒆𝒅𝒊𝒄𝒊𝒏𝒆 ) 𝑿 𝝆𝑷𝑴𝟐 (𝑷𝒓𝒆𝒔𝒄𝒓𝒊𝒑𝒕𝒊𝒐𝒏𝑴𝒆𝒅𝒊𝒄𝒊𝒏𝒆 )

𝑹𝒆𝒔𝒖𝒍𝒕 ← 𝚷𝑷𝒂𝒕𝒊𝒆𝒏𝒕𝑺𝑺𝑵 (𝑹𝟏 𝑿 𝑷𝒓𝒆𝒔𝒄𝒓𝒊𝒑𝒕𝒊𝒐𝒏)


Q.4) (25 points) We consider the following relation:
Articles(ID,title,journal,issue,year,startpage,endpage,TR-ID);
It contains information on articles published in scientific journals. Each article has a unique ID, a title, and
information on where to find it (name of journal, what issue, and on which pages). Also, if results of an
article previously appeared in a “technical report” (TR), the ID of this technical report can be specified.
We have the following information on the attributes:
• For each journal, an issue with a given number is published in a single year.
• The endpage of an article is never smaller than the startpage.
• There is never (part of) more than one article on a single page.
The following is an instance of the relation:

4
CENG315 INFORMATION MANAGEMENT
2016 FALL – MIDTERM - DEC. 5, 2016 - ANSWERS

STUDENT NAME AND NUMBER:


You Have 90 Minutes and Closed Book.

The following relations are also given for this table:

Articles1(journal,issue,year)
Articles2(ID,title,journal,issue,startpage,endpage)
Articles3(ID,TR-ID)

Consider the relations Authors(auID,name) and Authoring(articleID,authorID), containing


information on names of authors, and who is authoring which papers, respectively.

a) (5 points) Please indicate the primary key of this table and explain its reason.

Answer 4.a) The primary key for this table is {ID, TR-ID}, otherwise we could not identified tuples
uniquely.

b) (5 points) Write an SQL query that returns the titles of articles authored by 'Robert Tarjan'.

Answer 4.b)
SELECT title FROM Articles, Authors, Authoring
WHERE ID=articleID AND auID=authorID AND name='Robert Tarjan';

c) (5 points) Write an SQL query that returns the number of co-authors of 'Robert Tarjan'. (I.e.,
the number of authors who have written at least one article together with him.)

Answer 4.c)
SELECT COUNT(DISTINCT A2.authorID) FROM Authors, Authoring A1, Authoring A2
WHERE A1.authorID=auID AND name='Robert Tarjan' AND
A2.authorID<>auID AND A1.articleID=A2.articleID;

d) (10 points) Write SQL statements that correspond to the following two relational algebra
expressions. Duplicate elimination should be performed.

𝟏. ) 𝚷𝒕𝒊𝒕𝒍𝒆,𝒚𝒆𝒂𝒓 (𝝈𝒚𝒆𝒂𝒓=𝟐𝟎𝟎𝟓 (𝑨𝒓𝒕𝒊𝒄𝒍𝒆𝒔))

𝟐. ) 𝒈𝒚𝒆𝒂𝒓,𝑪𝑶𝑼𝑵𝑻(𝑰𝑫) (𝑨𝒓𝒕𝒊𝒄𝒍𝒆𝒔)

Answer 4.d)
1. SELECT DISTINCT title, year FROM Articles WHERE year=2005;
2. SELECT year,COUNT(ID) FROM Articles GROUP BY year;

5
CENG315 INFORMATION MANAGEMENT
2016 FALL – MIDTERM - DEC. 5, 2016 - ANSWERS

STUDENT NAME AND NUMBER:


You Have 90 Minutes and Closed Book.

REPRESENTATIONs:

Alternative representation. UML representation.

UML representation.

You might also like