Homework 1 - Purdue University

advertisement
CS54100 - Homework 1
Fall 2015
Due: Tuesday, October 6, 2015 in class, before class starts.
(There will be a 10% penalty for each late day. After 5 late days, the homework will not
be accepted.)
Part 1. E-R Diagram (30 points)
1. (20 points)
You are asked to design the E-R diagram of a conference management system. The system
manages computer science conferences including all the submissions and their details. State
any assumptions that you make. Make sure that your design captures the following aspects:
A. Information about the venues (e.g., VLDB, SIGMOD). Each venue has a starting year
(e.g., VLDB first conference was in 1975), and a lengthy textual description.
B. Information about the conference instances (e.g., SIGMOD'13, SIGMOD'14,
SIGMOD'15). Each conference instance holds the conference year, location, dates and
a single general chair (you can assume that a general chair is also an author).
C. Each conference instance has one or more research areas (e.g., Query processing,
Indexing, Data integration).
D. Information about the authors. Each author is affiliated to an institution and has an email.
E. Information about the submissions. Each submission has one or more authors, one of
them is the primary contact. The authors of a single submission are ordered (i.e., first
author, second author, etc).
F. Each submission is attached to a single conference instance and has one main primary
research area and one or more secondary research areas. Notice that
primary/secondary research areas are drawn from the same set.
2. (10 points)
Convert the E-R model you built into the corresponding relational model.
Part 2. Relational Algebra and Calculus (30 points)
Consider the ProjectsInfo relational schema given in Project 1. Write the following queries in
Relational Algebra (Questions 1,3,5,7,9, below), Query-By-Example (Questions 2,4,6,8,10,
below), Tuple Relational Calculus (Questions 1,3,5,7,9, below), and Domain Relational Calculus
(Questions 2,4,6,8,10, below). Note that some of these queries might not be expressible in
Relational Algebra, QBE, or Relational Calculus. For such queries, informally explain why they
cannot be expressed.
1. Find the names of employees who did not act as managers at any time.
2. Find the names of employees who did not work in more than three different projects.
3. Find the names of projects that have current working employees from more than two
different universities.
4. Find universities with the highest number of employees (More than one university may
qualify).
5. Find universities with the second highest number of employees (More than one
university may qualify).
6. Find employees who worked only with one manager.
7. Find employees who worked with all managers.
8. Find projects that were managed by managers graduated after 2010.
9. Find projects that were managed by only one manager.
10. Find departments that have at least one employee in every project.
Part 3. SQL (10 points)
Consider the ProjectsInfo relational schema given in Project 1.
Given the nested queries below,
A. State what each query computes, and
B. State, if any, the equivalent un-nested (single) SQL query.
1.
SELECT E.EmpName
FROM Employee E, Department D
WHERE E.DeptId = D.DeptId
AND D.DeptName = 'Development'
AND E.EmpId NOT IN
(
SELECT MgrId
FROM ProjectManager
);
2.
SELECT E.EmpName
FROM Employee E, Graduate G, University U
WHERE E.EmpId = G.EmpId
AND G.UnivId = U.UnivId
AND U.UnivName = 'Purdue'
AND G.GradYear = 1995
AND EXISTS
(
SELECT *
FROM Project P, ProjectManager PM
WHERE P.ProjId = PM.ProjId
AND PM.MgrId = E.EmpId
AND P.ProjName LIKE '%HR %'
);
Download