Advanced Query Formulation with SQL Week 10 Quiz Jaymond Huynh Tim Nguyen.

Slides:



Advertisements
Similar presentations
SQL: The Query Language Part 2
Advertisements

Chapter 4 Joining Multiple Tables
A Guide to SQL, Seventh Edition. Objectives Use joins to retrieve data from more than one table Use the IN and EXISTS operators to query multiple tables.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Data Bits Many to Many Subkeys JoinsQueries Attributes $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 Final DataBit.
1 Advanced SQL Queries. 2 Example Tables Used Reserves sidbidday /10/04 11/12/04 Sailors sidsnameratingage Dustin Lubber Rusty.
CSEN 5314 Quiz 4.
Introduction to SQL Session 2 Retrieving Data From Multiple Tables.
Introduction to Oracle9i: SQL1 Subqueries. Introduction to Oracle9i: SQL2 Chapter Objectives Determine when it is appropriate to use a subquery Identify.
CSEN 5314 Quiz What type of join is needed when you wish to include rows that do not have matching values? A. Equi-joinB. Natural join C. Outer.
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
1 DDL – subquery Sen Zhang. 2 Objectives What is a subquery? Learn how to create nested SQL queries Read sample scripts and book for different kinds of.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 9 Advanced Query Formulation with SQL.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 8 Advanced SQL.
Chapter 7 Advanced SQL Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems More SQL Database Design -- More SQL1.
Chapter 9 Advanced Query Formulation with SQL. Outline Outer join problems Type I nested queries Type II nested queries and difference problems Nested.
Advanced SQL SMSU Computer Services Short Course.
CSE314 Database Systems More SQL: Complex Queries, Triggers, Views, and Schema Modification Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Component 4/Unit 6f Topic VI: Create simple querying statements for the database The SELECT statement Clauses Functions Joins Subqueries Data manipulation.
Advanced SQL Murat Kantarcioglu Adapted from Silberchatz et al. slides.
Chapter 9 Joining Data from Multiple Tables
Week 10 Quiz 9 Answers Group 28 Christine Hallstrom Deena Phadnis.
Advanced Query Formulation with SQL. 9-2 Outline  Outer join problems  Type I nested queries  Type II nested queries and difference problems  Nested.
Chapter 9 Advanced Query Formulation with SQL. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Outer join problems.
9 Advanced Query Formulation with SQL (Chapter 9).
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 4: Intermediate.
Chapter 4Introduction to Oracle9i: SQL1 Chapter 4 Joining Multiple Tables.
Unit 4 Queries and Joins. Key Concepts Using the SELECT statement Statement clauses Subqueries Multiple table statements Using table pseudonyms Inner.
劉 志 俊 (Chih-Chin Liu) 中華大學 資訊工程系 October 2001 Chap 9 SQL (III): Advanced Queries.
I NTRODUCTION TO SQL II. T ABLE JOINS A simple SQL select statement is one that selects one or more columns from any single table There are two types.
Relational Databases.  In week 1 we looked at the concept of a key, the primary key is a column/attribute that uniquely identifies the rest of the data.
From Relational Algebra to SQL CS 157B Enrique Tang.
Programming in R SQL in R. Running SQL in R In this session I will show you how to: Run basic SQL commands within R.
SE305 Database System Technology 23/10/2014 Quiz-2.
Subqueries Steve Perry 1.
Module 4 Database SQL Tuning Section 3 Application Performance.
Chapter 12 Subqueries and Merge Statements
Subqueries.
Component 4: Introduction to Information and Computer Science Unit 6: Databases and SQL Lecture 6 This material was developed by Oregon Health & Science.
CS 405G: Introduction to Database Systems SQL III.
In this session, you will learn to: Query data by using joins Query data by using subqueries Objectives.
Jennifer Widom Relational Databases The Relational Model.
Quiz Which of the following is not a mandatory characteristic of a relation? Rows are not ordered (Not required) Each row is a unique There is a.
Chapter 7 Subqueries. Chapter Objectives  Determine when it is appropriate to use a subquery  Identify which clauses can contain subqueries  Distinguish.
Slide 1Chapter 9: Advanced Query Formulation with SQL Database Design, Application Development, and Administration, 5 th Edition Copyright © 2011 by Michael.
Slide 1 of 32ASH-Training Querying and Managing Data Using SQL Server 2014 By: Segla In this session, you will learn to: Query data by using joins Query.
Select Complex Queries Database Management Fundamentals LESSON 3.1b.
IFS180 Intro. to Data Management Chapter 10 - Unions.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
More SQL: Complex Queries,
Chapter 12 Subqueries and MERGE Oracle 10g: SQL
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Using Subqueries to Solve Queries
Chapter 4: Intermediate SQL Joins
SQL Structured Query Language 11/9/2018 Introduction to Databases.
Database Applications (15-415) SQL-Part II Lecture 9, February 04, 2018 Mohammad Hammoud.
Relational Databases The Relational Model.
Relational Databases The Relational Model.
SQL Views and Updates cs3431.
SQL – Entire Select.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
SQL Fundamentals in Three Hours
CMPT 354: Database System I
SQL: Structured Query Language
Using Subqueries to Solve Queries

Subqueries.
Geo-Databases: lecture 4 Complex Queries in SQL
Presentation transcript:

Advanced Query Formulation with SQL Week 10 Quiz Jaymond Huynh Tim Nguyen

Question 1 Which type of join should be used to include no-matching tuples from both tables in the results? Answer: D. A Full-Outer Join should be used to include no-matching tuples from both tables.

Question 2 Which clauses the SELECT statement can have nested queries: Answer: D. All of the above Nested queries can appear in FROM, WHERE, and HAVING clauses. A nested query typically appears as part of a condition in the WHERE and HAVING clauses. However, nested queries can also be used in the FROM clause.

Question 3 Which relational operation is very difficult to represent in SQL without nested queries Answer: C. Division Sql has no direct relational division operator. The only way to get around this is the have nested queries.

Question 4 Type II nested queries are not used for join problems because: Answer: A. Repeated executions make them inefficient for this purpose A Type II nested query executes one time for each row in the outer query.

Question 5 How many rows are there in the “student” table, if “select count(name) from student where gpa > 3” returns the number M and “select count(*) from student where gpa <= 3” returns the number N: Answer: B. >=M+N gpa > 3 will return the exclusive gpa”s without 3 and eh gpa <=3 will include 3 and all other gpas lower than 3. However, count(name) will only includes values that are not NULL. Not including NULL values will not show the number of rows, but the number of rows that are not NULL.

Question 6 Explain a situation when a full outer join is useful A full outer join can be useful to see relations between all entities. For instance, using a full outer join on two table allows the DBA to see relations between the two tables.