midterm-ans

midterm-ans - Fall, 2009 CIS 550 Database and Information...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Fall, 2009 CIS 550 Database and Information Systems Midterm Sample Solutions There are 90 points total, with up to 20 points of extra credit. Problem 1 [40 points]: Given our “bare bones” PennSocial schema: UserAccounts( userID : int, name : string, email : string, age : int, city : string) UserEducation( userID : int, school : string, startYear : int, finishYear : int) UserInterests( userID : int, interest : string) UserPartner( userID : int, partnerUserID : int, marriedToPartner : boolean) ConnectedTo( userID : int, friendUserID : int, privilegeLevel : int) Write each of the following queries. (a) (10pts) Find the users interested in “swimming” who are studying at Penn (assume finishYear is the predicted year of degree completion). Write this query in SQL . SELECT userID, name FROM UserAccounts UA, UserEducation UE, UserInterests UI WHERE UA.userID = UE.userID AND UA.userID = UI.userID AND UI.interest = ‘swimming’ AND UE.school = ‘Penn’ AND UE.finishYear > 2009 (b) (10pts) Find the IDs of users who have shared interests. Write this query in the relational algebra. Π userID,userID 2 ( UserInterest 1 interest = interest 2 userID 6 = userID 2 ( ρ userID,interest userID 2 ,interest 2 ( UserInterest )) (c) (10pts) Find the ID(s) of the “most popular” user(s), i.e., the one(s) connected to the most friends (note there can be a tie). Write this query in the tuple relational calculus. Impossible: This query is not expressible in the TRC. Note: this question will be counted as extra credit since the instructions to use the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 10/31/2010.

Page1 / 5

midterm-ans - Fall, 2009 CIS 550 Database and Information...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online