{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

midterm-ans

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

This preview shows pages 1–3. Sign up to view the full content.

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 answer “Impossible” were inadvertently omitted on the text of the exam (though an- nounced in class) 1

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

View Full Document
(d) (10pts) Find the user(s) who has(have) enrolled in the most schools.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

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

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

View Full Document
Ask a homework question - tutors are online