The University of British Columbia

Similar documents
Carnegie Mellon University Department of Computer Science /615 - Database Applications C. Faloutsos & A. Pavlo, Spring 2014.

Spring 2016 Stony Brook University Instructor: Dr. Paul Fodor

Lottery Results

Focus of the Unit: Much of this unit focuses on extending previous skills of multiplication and division to multi-digit whole numbers.

Welcome to SAT Brain Boot Camp (AJH, HJH, FJH)

Possessive have and (have) got in New Zealand English Heidi Quinn, University of Canterbury, New Zealand

Oak Park and River Forest High School District 200 Board of Education May 22, 2014 Personnel Report

Managing the Student View of the Grade Center

Bibliography. Allen, Daniel. "Volunteering Works." Mental Health Practice 11.9 (2008): 6-7. Academic

Evaluating Statements About Probability

Answers To Managerial Economics And Business Strategy

Teacher: Mlle PERCHE Maeva High School: Lycée Charles Poncet, Cluses (74) Level: Seconde i.e year old students

Dorothy Wright Simes papers,

The School Report Express. FYI Picayune

CAAP. Content Analysis Report. Sample College. Institution Code: 9011 Institution Type: 4-Year Subgroup: none Test Date: Spring 2011

Welcome to ACT Brain Boot Camp

Santa Barbara Peace Corps Association Members ALPHABETICAL ORDER by last name (as of 4/8/13)

Managerial Economics 12th Edition Answers

Are You Ready? Simplify Fractions

The Basics Of Heat (Core Concepts) By John O. E. Clark

Stochastic Calculus for Finance I (46-944) Spring 2008 Syllabus

Rottenberg, Annette. Elements of Argument: A Text and Reader, 7 th edition Boston: Bedford/St. Martin s, pages.

Building Bridges Globally

Intra-talker Variation: Audience Design Factors Affecting Lexical Selections

A Level Business Studies Past Papers

ENGL 213: Creative Writing Introduction to Poetry

GENERAL BUSINESS 7397, section 18842: BOOKS AN MBA SHOULD READ

Algebra 1 Summer Packet

Room: Office Hours: T 9:00-12:00. Seminar: Comparative Qualitative and Mixed Methods

Sociology. Faculty. Emeriti. The University of Oregon 1

NANCY L. STOKEY. Visiting Professor of Economics, Department of Economics, University of Chicago,

Virtually Anywhere Episodes 1 and 2. Teacher s Notes

Middle States Commission on Higher Education 3624 Market Street, Philadelphia, PA Phone: Fax:

WASC Special Visit Research Proposal: Phase IA. WASC views the Administration at California State University, Stanislaus (CSUS) as primarily

Macroeconomic Theory Fall :00-12:50 PM 325 DKH Syllabus

INSTRUCTIONAL MATERIALS SURVEY ELEMENTARY SCHOOL LEVEL RLA/ELD WORKSHEET

Rajiv Gandhi National University of Law, Punjab (India) RGNUL Exagium: Essays on Classics

Special Edition. Starter Teacher s Pack. Adrian Doff, Sabina Ostrowska & Johanna Stirling With Rachel Thake, Cathy Brabben & Mark Lloyd

PHILOSOPHY & CULTURE Syllabus

Association Between Categorical Variables

MATH 205: Mathematics for K 8 Teachers: Number and Operations Western Kentucky University Spring 2017

Exhibit 2. WJMZ-FM, WHZT (FM) WJMZ-FM, Anderson, South Carolina / WHZT (FM), Seneca, South Carolina May 3, July 31, 2013

Integrating Common Core Standards and CASAS Content Standards: Improving Instruction and Adult Learner Outcomes

Activity Insight Faculty User Guide

Mcgraw Hill 2nd Grade Math

ENCE 215 Applied Engineering Science Spring 2005 Tu/Th: 9:00 am - 10:45 pm EGR Rm. 1104

Syllabus: Introduction to Philosophy

TCC Jim Bolen Math Competition Rules and Facts. Rules:

CONCEPT MAPS AS A DEVICE FOR LEARNING DATABASE CONCEPTS

Spanish Version Of Nihss Scale

Mrs. Helmberger s Class Newsletter

Playing It By Ear The First Year of SCHEMaTC: South Carolina High Energy Mathematics Teachers Circle

5 Guidelines for Learning to Spell

APA Basics. APA Formatting. Title Page. APA Sections. Title Page. Title Page

Workshop 5 Teaching Multigenre Writing

10-Year Priority List

Columbia County School System Preliminary Rezoning Proposal

Filing RTI Application by your own

Syllabus Introduction to the Human Context of Science and Technology HCST 100 & HCST 100H FALL 2007 Rev. 3 IN WORK Changes in color

Cerritos Community College District Organizational Chart

Boston MA Visitors Street Map By American Map

Extending Place Value with Whole Numbers to 1,000,000

MBA 510: Critical Thinking for Managers

BMBF Project ROBUKOM: Robust Communication Networks

Evaluation of Respondus LockDown Browser Online Training Program. Angela Wilson EDTECH August 4 th, 2013

PBHL HEALTH ECONOMICS I COURSE SYLLABUS Winter Quarter Fridays, 11:00 am - 1:50 pm Pearlstein 308

JING: MORE BANG FOR YOUR INSTRUCTIONAL BUCK

MASP: Building a System of Support for ALL Michigan s Students. Michigan Association of School Psychologists

CHANCERY SMS 5.0 STUDENT SCHEDULING

July Sun Mon Tue Wed Thu Fri Sat. New Teacher Orientation July Mr. Rodriguez s. Mrs. Leon s Birthday Birthday. Mr.

Mike Cohn - background

THE MEN BEHIND THE PULPIT (RICHMOND HILL BAPTIST CHURCH, YADKIN BAPTIST ASSOCIATION) - NCCF. November June 1901

GIS 5049: GIS for Non Majors Department of Environmental Science, Policy and Geography University of South Florida St. Petersburg Spring 2011

Seven Steps To Effective Delegation. featuring Bob Johnson

SUMMARY REPORT MONROE COUNTY, OH OFFICIAL RESULTS PRIMARY ELECTION MARCH 6, 2012 RUN DATE:03/20/12 11:03 AM STATISTICS REPORT-EL45 PAGE 001

Longitudinal Analysis of the Effectiveness of DCPS Teachers

Paper: Collaborative Information Behaviour of Engineering Students

Sight Word Assessment

How to make an A in Physics 101/102. Submitted by students who earned an A in PHYS 101 and PHYS 102.

Changing Majors. You can change or add majors, minors, concentration, or teaching fields from the Student Course Registration (SFAREGS) form.

Task Tolerance of MT Output in Integrated Text Processes

Iterative Cross-Training: An Algorithm for Learning from Unlabeled Web Pages

Our installer John Stoddard was polite, courteous, and efficient. The order was exactly as we had placed it and we are very satisfied.

Data Modeling and Databases II Entity-Relationship (ER) Model. Gustavo Alonso, Ce Zhang Systems Group Department of Computer Science ETH Zürich

Linking the Library and the Course Management System. Claire Dygert American University Library NASIG Annual Conference 2006

The Strong Minimalist Thesis and Bounded Optimality

Math Hunt th November, Sodalitas de Mathematica St. Xavier s College, Maitighar Kathmandu, Nepal

Syllabus: PHI 2010, Introduction to Philosophy

Empiricism as Unifying Theme in the Standards for Mathematical Practice. Glenn Stevens Department of Mathematics Boston University

Beginners French FREN 101 University Studies Program. Course Outline

Hill, Ronald P. and Langan, Ryan (2014), Handbook of Research on Marketing and Corporate Social Responsibility Edward Elgar Publishing, forthcoming

Parallel Evaluation in Stratal OT * Adam Baker University of Arizona

Hawker Brownlow Education. Looking Together at Student Work. Tina Blythe David Allen Barbara Schieffelin Powell THIRD EDITION

CollegeNow Conference Day Breakout Session I 10:40 AM 11:55 AM

Multiplication of 2 and 3 digit numbers Multiply and SHOW WORK. EXAMPLE. Now try these on your own! Remember to show all work neatly!

South Carolina English Language Arts

Earthsoft s EQuIS Database Lower Duwamish Waterway Source Data Management

NUMBERS AND OPERATIONS

HIS/IAR 627: Museum and Historic Site Interpretation

NORTH CAROLINA VIRTUAL PUBLIC SCHOOL IN WCPSS UPDATE FOR FALL 2007, SPRING 2008, AND SUMMER 2008

Transcription:

The University of British Columbia Computer Science 304 Midterm Examination March 2, 2012 Time: 50 minutes Total marks: 60 Instructor: Rachel Pottinger Name ANSWER KEY (PRINT) (Last) (First) Signature This examination has 3 doublesided pages. Check that you have a complete paper. This is a closed book, closed notes exam. No books or other material may be used. Answer all the questions on this paper. Give very short but precise answers. State any assumptions you make Work fast and do the easy questions first. Leave some time to review your exam at the end. Good Luck Question Mark Out of 1.a 10 1.b 10 2.a 10 2.b 10 2.c 10 2.d 10 TOTAL Out of 60

All queries for this exam use the same schema as in class and in the SQL exercises in the book: Student(snum: integer, sname: string, major: string, level: string, age: integer) Class(name: string, meets_at: string, room: string, fid: integer) Enrolled(snum: integer, cname: string) Faculty(fid: integer, fname: string, deptid: integer) The schema will be repeated on following pages for easy reference. The meaning of these relations is straightforward; for example, Enrolled has one record per student-class pair such that the student is enrolled in the class. 1. {20 marks} Relational Algebra. For each query return EXACTLY the following: a. Find the names of all students who have taken at least two classes taught by Elizabeth Taylor (class1, snum, sname, cname ((student enrolled cname = name class ( fname = Elizabeth Taylor faculty))) (class2, snum, sname, cname ((student enrolled cname = name class ( fname = Elizabeth Taylor faculty))) sname (class1 class1.snum = class2.snum ^ class1.cname <> class2.cname class2) b. Find the student numbers of the students who have taken classes from teachers with the same name (e.g., you d return the student ID of the student John Williams if he took a class from John Williams ) Note: this is very similar to practice question # 1a from the practice Midterm #11. The answer is as follows FT fname, name (Class Faculty) SE sname, snum, cname (Student Enrolled) Π snum (SE name = cname sname = fname FT) Page 2

The schema again: Student(snum: integer, sname: string, major: string, level: string, age: integer) Class(name: string, meets_at: string, room: string, fid: integer) Enrolled(snum: integer, cname: string) Faculty(fid: integer, fname: string, deptid: integer) 2. {40 marks} SQL Queries. For each query return EXACTLY the following (i.e., remove duplicates from your final answers where they are not explicitly requested, and include no extra columns): a. Find the name of the faculty member(s) who taught the most number of unique students and how many students they taught CREATE VIEW taught AS SELECT f.fid, count(distinct e.snum) as count FROM faculty f, enrolled e, class c WHERE f.fid = c.fid and c.name = e.cname GROUP BY f.fid SELECT f.fname, t1.count FROM taught t1, faculty f WHERE f.fid = t1.fid AND t1. count >= ALL (SELECT count FROM taught t2) FNAME COUNT -------------------------------------- Linda Davis 6 Note: need to rename count(*), or it won t work Note: need to say which fid you re grouping by, and has to be the same one in the select clause Note: can t do this in one query (unless there s some very clever nesting involved) Page 3

b. Find an alphabetical list of the names of all students who have not taken a class taught by the faculty member with ID 489456522 SELECT sname FROM student s WHERE s.snum not in (select e.snum FROM enrolled e, class c WHERE e.cname = c.name and c.fid = 489456522) ORDER BY sname SNAME ------------------------------ Angela Martinez Betty Adams Charles Harris Daniel Lee Donald King Dorthy Lewis Edward Baker George Wright Juan Rodriguez Kenneth Hill Margaret Clark Maria White Mark Young Nancy Allen Paul Hall Steven Green Susan Martin Thomas Robinson Page 4

c. List each major majored in by at least 2 students whose student IDs begin with 3 select major from student where snum like '3%' group by major having count(*) > 1 MAJOR ------------------------- Computer Science Note that you can also do this one by comparing two separate students and ensuring that the two students have the same major but different student numbers. In that case, you MUST have DISTINCT in the select clause. Here, having DISTINCT in the select clause won t hurt anything, but since it s done by a group, each major will only be returned once anyway. Page 5

d. Find the names of all students who are enrolled in two classes that meet at the same time Note: this is question 5.1.4 from the book 1 select distinct s.sname 2 from student s 3 where s.snum in (select e1.snum 4 from enrolled e1, enrolled e2, class c1, class c2 5 where e1.snum = e2.snum and e1.cname <> E2.cname 6 and E1.cname = C1.name 7 and e2.cname = c2.name and c1.meets_at = c2.meets_at) SNAME ------------------------------ Luis Hernandez Page 6