• Test Prep
• 9
• 100% (4) 4 out of 4 people found this document helpful

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

Midterm Exam CMPS 182, Summer 2017, UCSC August 3, 2017 STUDENT ’S NAME: _________________________________________________________________________ STUDENT ’S CRUZID (first part of email): ______________________________________________ Part Score Max Part Score Max 1 30 4 28 2 10 5 18 3 14 Part I (30 points): Query Results Questions 1-6 are about the Bars domain tables, which are being provided on 2 separate sheets of paper. What is the result of each of the following queries? (Show attribute names at the top in all results. If the query does not specify ORDER BY then any order will do.) Question 1 (4 points): SELECT Name, Capacity FROM Bars WHERE Zip = 95010; Answer 1 : Name Capacity ------------------------------------------------ Relational Expressions 8 SUM of the Parts 10 Question 2 (4 points): SELECT DISTINCT City, Zip FROM Bars WHERE Capacity >= 20; Answer 2 :

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

City Zip ----------------------------------- Santa Cruz 95064 Monterey 93940 San Francisco 94101 San Francisco 94102 Question 3 (5 points): SELECT Beer FROM Bars, Sells WHERE Bar = Name AND City = ‘Santa Cruz’ INTERSECT SELECT Beer FROM Bars, Sells WHERE Bar = Name AND City = ‘ Woodside ; Answer 3 : Beer ------------ Heineken Sapporo Question 4 (5 points): SELECT Beer, MAX(Price) FROM Sells GROUP BY Beer; Answer 4 : Beer MAX(Price) ------------------------------------------ Budweiser 4.00 Molson Golden 6.00 Heineken 7.00 Sapporo 6.00 Question 5 (6 points): SELECT DISTINCT S1.Bar FROM Sells S1 WHERE S1.Price < ALL (SELECT S2.Price FROM Sells S2 WHERE S2.Bar = ‘Select Clientele’ ) ;
Answer 5 : S1.Bar --------- Chugs and Slugs Hi Bar Question 6 (6 points) (a query expressed in relational algebra): Drinker, Beer ( Frequents.Bar = Sells.Bar AND Sells.Price > 6.50 (Frequents x Sells)) Answer 6 : Drinker Beer --------------------------------- Barack Heineken Dmitri Heineken PART II (10 points). YES/NO and multiple-choice, 1 point each. Circle the correct answer for each question (or circle the letter next to the answer, whichever you prefer). Question 7: If we assume that {Bar, Beer} is the primary key for the attached Sells table, what can we say about {Bar, Beer, Price}? a. It could be declared as UNIQUE b. It is a key c. It is a super key d. None of the above Answer 7: b. It is a super key Question 8 : The purpose of indexing is to maintain consistency between tables. a. YES b. NO Answer 8: NO Question 9 : Which of the following is most likely to be a reasonable primary key for the Bars table?

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

a. {Name} b. {City} c. {City, Zip} d. {City, Zip, Capacity} Answer 9: a. {Name} Question 10 : There can be multiple keys for a relation.
This is the end of the preview. Sign up to access the rest of the document.
• Fall '08
• Polyzotis,N

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern