0% found this document useful (0 votes)
24 views3 pages

Sample Final 2

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

Sample Final 2

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

Computer and Information Science 631

Final Examination

• Examination Duration: 3hrs

• This is not an open book examination. But you are allowed to bring to the exam one sheet of
paper HAND-WRITTEN on both sides (if needed). On this sheet of paper you can write down what
you think you will need for the exam.
• There is no question during the exam. If you are unsure, write down your assumptions
• The total points is 100

1 Database Design [34]


BestSore is a leading supermarket and would like you to design its database. Bestore has several employees
among which drivers, manager, salespersons. BestStore is composed of several departments and an employee
works for one and only one department. A department has a name a speciality and a manager. For an
employee, the following information is recorded: employee number, name and address. The store possesses
different cars (model, year and license plate are recorded for each of them) grouped into types (truck, trailer,
sedan...). For employees that are drivers, the supermarket stores the type of vehicle (truck, trailer, sedan..),
they are allowed to drive. The majority of the departments sale items. But some departments like
”Logistics” and ”Supply” service the departments that sale. An item is sold by one and only one
departments and has: name, manufacturer, price, model number (assigned by the manufacturer), and an
internal item number (assigned by the store). A manufacturer is identified by a unique vendor id and has a
name, and address. The store would like to know which items a manufactures supplies and their prices.

1. Propose an entity-relationship (ER) diagram to model this information system. For each of the
entities, feel free to add attributes if needed.
2. Give a step by step mapping of the ER diagram to the relational model. Explain your decisions.

2 Query Processing [15]


Consider these proposed equivalences:
ΠA(R —S) = ΠA(R) −ΠA(S)
σB<4(max(B)(R)) = max(B)(σB<4(R)) [max is a function that returns the maximum value of

1
an attribute]
Argue, by means of examples or counterexamples about the correctness of these equivalences. What
happens if in the second, max is replaced by min?

3 Query Processing and Physical Design[15]


Let relations R(A,B,D) and R(B,C,E) be given,and consider the SQL query: select A
from R, S
where R.B = S.B
and R.D > 200
• Propose an optimized execution plan

• Describe a way to implement this query efficiently, in particular suggest how to organize R and S
(that is, whether they are sorted [clustered] and if so with regard to which attribute(s), which
kind of index structure is used, etc.)

4 Database Querying [36]


Consider the database consisting of the following relations:
Flights(Flno: integer, From: string, To: string, Distance: integer, departs: Time, Arrives: time) Flight
Instance(Flno: integer, Day: date, Aid: Integer)
Aircraft(Aid: integer, Make: string, Model: string, CrusingRange: string) Certified(Eid:
integer, Make: string, Model: string)
Employee(Eid: integer, Ename: string, Salary: integer)
Fight Attendant(Flno: integer, Day: date, Eid:integer, Role: string)
The Flight table contains general information about the flights whereas the Flight Instance is about a flight
number on a specific date. Aircraft list the aircrafts in the company, the make is the company that made the
aircraft (e.g. Boing, Airbus) and the model is for example 747 for Boing or 321 for Airbus. The table
Certified tells which employees can fly which airplanes, the tables Fight Attendant assigns employees to
specific flights with a role (e.g. captain). Finally, the table Employee lists the employees of the airline
company.
Express the following queries (I) in Tuple Relational Calculus (1 and 2), (II) in Algebra
(3 to 4), (III) in SQL (1 to 5):
1. List the crew members of the flight 123 on May 5, 2005
{E.Ename∣∃FA(FA.Flno=123∧FA.Day=DATE(′2005−05−05′)∧E.Eid=FA.Eid)}
SELECT E.Ename
FROM Employee E
JOIN FlightAttendant FA ON E.Eid = FA.Eid
WHERE FA.Flno = 123 AND FA.Day = '2005-05-05';
2. List the flight attendants who flew to Chicago at list once since January 1st 2005.

{E.Ename∣∃FA∃FI∃F(FA.Eid=E.Eid∧FA.Flno=FI.Flno∧FA.Day=FI.Day∧FI.Flno=F.Flno∧F.To=
′Chicago′∧FI.Day≥DATE(′2005−01−01′))}

2
SELECT DISTINCT E.Ename
FROM Employee E
JOIN FlightAttendant FA ON E.Eid = FA.Eid
JOIN FlightInstance FI ON FA.Flno = FI.Flno AND FA.Day = FI.Day
JOIN Flights F ON FI.Flno = F.Flno
WHERE F.To = 'Chicago' AND FI.Day >= '2005-01-01';
3. Find the employees who flew only to Chicago.
SELECT E.Ename
FROM Employee E
JOIN FlightAttendant FA ON E.Eid = FA.Eid
JOIN FlightInstance FI ON FA.Flno = FI.Flno AND FA.Day = FI.Day
JOIN Flights F ON FI.Flno = F.Flno
GROUP BY E.Eid, E.Ename
HAVING COUNT(DISTINCT F.To) = 1 AND MAX(F.To) = 'Chicago';
4. List the employees who have been to all the cities
SELECT E.Ename
FROM Employee E
JOIN FlightAttendant FA ON E.Eid = FA.Eid
JOIN FlightInstance FI ON FA.Flno = FI.Flno AND FA.Day = FI.Day
JOIN Flights F ON FI.Flno = F.Flno
GROUP BY E.Eid, E.Ename
HAVING COUNT(DISTINCT F.To) = (SELECT COUNT(DISTINCT To) FROM Flights);
5. List the employee who has travelled the most [in term of number of flights].
SELECT E.Ename
FROM Employee E
JOIN FlightAttendant FA ON E.Eid = FA.Eid
GROUP BY E.Eid, E.Ename
ORDER BY COUNT(*) DESC
LIMIT 1;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy