Midterm 1 157A Fall /22

Similar documents
Joins, NULL, and Aggregation

State your dream system (use the following materials, if you need) Alliance model character year character 4. A/T description character 51

SQL queries II. Set operations and joins

Database Modifications and Transactions

Information Systems for Engineers. Exercise 10. ETH Zurich, Fall Semester Hand-out Due

Relational Algebra. Spring 2012 Instructor: Hassan Khosravi

Relational Model, Key Constraints

Data Definition Language (DDL), Views and Indexes Instructor: Shel Finkelstein

Programming and Database Fundamentals for Data Scientists

Set Operations, Union

AC61/AT61 DATABASE MANAGEMENT SYSTEMS DEC 2013

Niklas Fors The Relational Data Model 1 / 17

Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa

1. Given the name of a movie studio, find the net worth of its president.

Optimization of logical query plans Eliminating redundant joins

Algebraic laws extensions to relational algebra

Midterm Review. Winter Lecture 13

Database Systems. Basics of the Relational Data Model

Improving Query Plans. CS157B Chris Pollett Mar. 21, 2005.

Query Processing & Optimization. CS 377: Database Systems

Information Systems Engineering. SQL Structured Query Language DML Data Manipulation (sub)language

Relational Model, Relational Algebra, and SQL

Exam I Computer Science 420 Dr. St. John Lehman College City University of New York 12 March 2002

Query Processing and Optimization

Database Systems Architecture. Stijn Vansummeren

Relational Model and Relational Algebra

Isolation Levels and Concurrency

Final Examination Computer Science 420 Dr. St. John Lehman College City University of New York 21 May 2002

Database Technology. Topic 2: Relational Databases and SQL. Olaf Hartig.

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 2: Relations and SQL. September 5, Lecturer: Rasmus Pagh

Faloutsos - Pavlo CMU SCS /615

Overview. Carnegie Mellon Univ. School of Computer Science /615 - DB Applications. Concepts - reminder. History

Background material for Chapter 3 taken from CS 245

COMP102: Introduction to Databases, 5 & 6

Introduction to Database Design, fall 2011 IT University of Copenhagen. Normalization. Rasmus Pagh

Intermediate SQL ( )

Informationslogistik Unit 4: The Relational Algebra

CSEP 514 Midterm. Tuesday, Feb. 7, 2017, 5-6:20pm. Question Points Score Total: 150

RELATIONAL ALGEBRA. CS 564- Fall ACKs: Dan Suciu, Jignesh Patel, AnHai Doan

Birkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6)

Relational Algebra and SQL

Database Management Systems Paper Solution

CMP-3440 Database Systems

Database design process

Exam II Computer Programming 420 Dr. St. John Lehman College City University of New York 20 November 2001

RELATIONAL ALGEBRA. CS121: Relational Databases Fall 2017 Lecture 2

A Sample Solution to the Midterm Test

The SQL data-definition language (DDL) allows defining :

Supplier-Parts-DB SNUM SNAME STATUS CITY S1 Smith 20 London S2 Jones 10 Paris S3 Blake 30 Paris S4 Clark 20 London S5 Adams 30 Athens

CSE 344 JANUARY 26 TH DATALOG

Database Technology. Topic 3: SQL. Olaf Hartig.

Chapter 2: Intro to Relational Model

Midterm Exam. October 30th, :15-4:30. CS425 - Database Organization Results

Mahathma Gandhi University

Basant Group of Institution

Database Systems SQL SL03

Database Systems SQL SL03

CSE-3421M Test #2. Queries

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13

CS 582 Database Management Systems II

2.2.2.Relational Database concept

Comp 5311 Database Management Systems. 2. Relational Model and Algebra

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects.

Databases. Jörg Endrullis. VU University Amsterdam

Database Systems CSE 303. Lecture 02

Database Systems CSE 303. Lecture 02

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Data Structure: Relational Model

CS222P Fall 2017, Final Exam

CS 327E Lecture 2. Shirley Cohen. January 27, 2016

Database System Concepts

Introduction to Database Systems. Announcements CSE 444. Review: Closure, Key, Superkey. Decomposition: Schema Design using FD

Querying Data with Transact SQL

IMPORTANT: Circle the last two letters of your class account:

SQL. CS 564- Fall ACKs: Dan Suciu, Jignesh Patel, AnHai Doan

5.2 E xtended Operators of R elational Algebra

Relational Algebra. Relational Algebra. 7/4/2017 Md. Golam Moazzam, Dept. of CSE, JU

THE AUSTRALIAN NATIONAL UNIVERSITY. Mid-Semester Examination August 2006 RELATIONAL DATABASES (COMP2400)

Chapter 3: Introduction to SQL

Chapter 3: Relational Model

Outline. Query Processing Overview Algorithms for basic operations. Query optimization. Sorting Selection Join Projection

Chapter 2: Intro to Relational Model

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,

MIS Database Systems Relational Algebra

Relational Algebra. Procedural language Six basic operators

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2006 Lecture 3 - Relational Model

Midterm Exam #2 (Version A) CS 122A Winter 2017

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

ACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)

CS34800 Information Systems. The Relational Model Prof. Walid Aref 29 August, 2016

v Conceptual Design: ER model v Logical Design: ER to relational model v Querying and manipulating data

Introduction. Sample Database SQL-92. Sample Data. Sample Data. Chapter 6 Introduction to Structured Query Language (SQL)

Selection and Projection

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #3: SQL and Rela2onal Algebra- - - Part 1

I will not use a source other than my brain on this exam: (please sign)

Relational Algebra. Mr. Prasad Sawant. MACS College. Mr.Prasad Sawant MACS College Pune

CS275 Intro to Databases

COMP 244 DATABASE CONCEPTS AND APPLICATIONS

Relational Query Languages: Relational Algebra. Juliana Freire

CSIT5300: Advanced Database Systems

Transcription:

Midterm 1 157A Fall 2012 10/22 Class-id Name Part III Describe your contribution in the team project before mid night today. Part I Questions and Answers (10 pts EACH) 1. (DB3) Please write SQL for (a) σ length>=100 (MOVIES) (b) π title, year, length (MOVIES) 2. (DB1) Let SUPPLIERS and PARTS relations be denoted by S and P respectively Please write SQL for (a) Cartesian Product (b) Natural Join S P S P 3. (DB2) Please write an SQL to retrieval the last name(l) of each employee whose home address contains BELLAIRE

4 (DB2) Write the output of or the meaning in English in the following SQL SELECT E.SSN, E.F, E.L FROM EMPLOYEE E WHERE EXISTS (SELECT * FROM DEPENDENT D WHERE E.SSN = D.DEPSSN) AND EXISTS (SELECT * FROM DEPARTMENT P WHERE E.SSN =P.MGRSSN); 5. (DB3) Please write an SQL to retrieve supplier s names who supply P2. Key

Part II 1. (DB3) To retrieves title of the movies whose length is unknown Which of the following SQL is correct a) SELECT Title WHERE length is null; b) SELECT Title WHERE length = null; c) SELECT Title WHERE length = 0; d) None of the above 2. (DB1) SELECT FROM WHERE ORDER a) S3 30 S2 10 b) S2 10 S3 30 c) S3 10 S2 30 d) S2 30 S3 10 e) None of the above SNUM, STATUS SUPPLIERS CITY = 'PARIS' BY STATUS DESC; 3. (DB3) The output of the following SQL is a relation whose column names are SELECT title as Name, length as Hours WHERE studioname = 'DISNEY' and AND year = 1990; (a) Title and length (b) Name and Hours (c) Both are correct (d) Both are incorrect (e) None of the above

4. (DB3) SELECT *, MovieExec WHERE title = 'STAR''s WARS' AND producerc# = cert#; What kind of operation is this SQL performing a) Equi join b) Natural join c) Cartesian product d) Inequality join e) None of the above 5. SELECT S FROM SUPPLIERS s, (SELECT SNUM FROM SHIPMENTS WHERE PNUM='P2') t Where s.snum = t.snum; What kind of operation is this SQL performing a) Temp Join query b) Join query c) Sub query d) None of the above 6. Will the following SQL SELECT S FROM SUPPLIERS s, SHIPMENTS sh Where sh. pnum='p2' and s.snum = sh.snum; Produces the same result as previous one 7. SELECT Star1.name, Star2.name FROM MovieStar Star1, MovieStar Star2 WHERE Star1.address = Star2.address AND Star1.name < Star2.name; The role of the second condition is to avoid the repetition of outputs What would happen if we use <>? a) The output will not repeat b) The output will repeat c) None of the above

8. The schema of Movies_e indicates TITLE has data type VARCHAR2(22) The schema of Starsin_e indicates MOVIETITLE has data type CHAR2(22) The output of (SELECT title _e) Intersect (SELECT movietitle _e); is always no row selected. Why? a) Because the data types of title and movietitle are different b) Some rows may be selected 9. (DB3) WHERE cert# IN WHERE (title, year) IN Who should be in the output: a) JAMES CAMERON b) DANNY BOYLE c) PETER JACKSON d) CATHERINE WINDER e) None of the above 10. (DB3) What will be the output of following query : WHERE cert# NOT in WHERE (title, year) IN

Whose should NOT be in the output: a) JAMES CAMERON b) CATHERINE WINDER c) DANNY BOYLE d) Darren Aronofsky e) DAN BRODER Extra credits 11. (DB3) : WHERE cert# = WHERE (title, year) IN JAMES CAMERON 12. (DB3) : WHERE cert# = WHERE (title, year) NOT IN

ERROR at line 4: RA-01427: single-row subquery returns more than one row 13. (DB3) : WHERE cert# in WHERE (title, year) NOT IN CATHERINE WINDER DANNY BOYLE Darren Aronofsky DAN BRODER