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

Similar documents
CS 327E Lecture 3. Shirley Cohen. February 1, 2016

CS 327E Lecture 5. Shirley Cohen. February 8, 2016

CS 327E Lecture 10. Shirley Cohen. February 29, 2016

CS 327E Lecture 5. Shirley Cohen. September 14, 2016

Introduction to Databases and SQL

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

CS 327E Lecture 11. Shirley Cohen. March 2, 2016

Private Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH

Structured Query Language (SQL) Part A. KSE 521 Topic 10 Mun Yi

Downloaded from

CSC Web Programming. Introduction to SQL

EE221 Databases Practicals Manual

Exam code: Exam name: Database Fundamentals. Version 16.0

How to use SQL to create a database

Data about data is database Select correct option: True False Partially True None of the Above

CS W Introduction to Databases Spring Computer Science Department Columbia University

Unit 1 - Chapter 4,5

SELECT Product.name, Purchase.store FROM Product JOIN Purchase ON Product.name = Purchase.prodName

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

SQL Commands & Mongo DB New Syllabus

Working with Databases and Java

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

CS 327E Lecture 12. Shirley Cohen. March 7, 2016

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

Database Management Systems,

An Introduction to Structured Query Language

Lecture 2: Introduction to SQL

Database Programming with SQL

CMPT 354: Database System I. Lecture 3. SQL Basics

MIS2502: Data Analytics SQL Getting Information Out of a Database Part 1: Basic Queries

Table Joins and Indexes in SQL

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014

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

Chapter 13 : Informatics Practices. Class XI ( As per CBSE Board) SQL Commands. New Syllabus Visit : python.mykvs.in for regular updates

Retrieving Data Using the SQL SELECT Statement. Copyright 2009, Oracle. All rights reserved.

Database Management Systems,

Advance Database Systems. Joining Concepts in Advanced SQL Lecture# 4

More MySQL ELEVEN Walkthrough examples Walkthrough 1: Bulk loading SESSION

Relational Database Languages

1Z Oracle Database 11g - SQL Fundamentals I Exam Summary Syllabus Questions

History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)

Lecture 04: SQL. Wednesday, October 4, 2006

Lecture 2: Chapter Objectives. Relational Data Structure. Relational Data Model. Introduction to Relational Model & Structured Query Language (SQL)

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints

Lecture 2: Chapter Objectives

GlobAl EDITION. Database Concepts SEVENTH EDITION. David M. Kroenke David J. Auer

INF 315E Introduction to Databases School of Information Fall 2015

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Lecture 5. Monday, September 15, 2014

SQL Server 2008 Tutorial 3: Database Creation

Relational Database Development

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

MySQL. Prof.Sushila Aghav

Chapter-14 SQL COMMANDS

Operating systems fundamentals - B07

SQL. Char (30) can store ram, ramji007 or 80- b

Simple Quesries in SQL & Table Creation and Data Manipulation

Databases - Classic Models

Basic SQL. Dr Fawaz Alarfaj. ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation

COGS 121 HCI Programming Studio. Week 03 - Tech Lecture

MySQL Query Tuning 101. Sveta Smirnova, Alexander Rubin April, 16, 2015

An Introduction to Structured Query Language

Data Infrastructure IRAP Training 6/27/2016

Basic SQL. Basic SQL. Basic SQL

Introduction to Database Systems CSE 414

An Introduction to Structured Query Language

Oracle 1Z MySQL 5.6 Developer.

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002.

CSE 344 JANUARY 5 TH INTRO TO THE RELATIONAL DATABASE

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

This homework contains 8 pages. Please scroll down to see all of the pages.

L Information Systems for Engineers. Final exam. ETH Zurich, Autumn Semester 2017 Friday

An Introduction to Structured Query Language

CHAPTER 16. More on SQL- Grouping Records and Table Joins

MySQL by Examples for Beginners

An Introduction to Structured Query Language

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language

Unit 27 Web Server Scripting Extended Diploma in ICT

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

T-SQL Training: T-SQL for SQL Server for Developers

Midterm Review. Winter Lecture 13

SQL (Structured Query Language)

user specifies what is wanted, not how to find it

Constraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2

ITCertMaster. Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way!

CMPT 354: Database System I. Lecture 2. Relational Model

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus Lecture #23: SQLite

Assignment 6: SQL III Solution

CLASS DISCUSSION AND NOTES

Translating an ER Diagram to a Relational Schema

Chapter 4: SQL Basics

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL

1Z0-071 Exam Questions Demo Oracle. Exam Questions 1Z Oracle Database 12c SQL.

Practical 8. SHANKER SINH VAGHELA BAPU INSTITUTE OF TECHNOLGY Subject: - DBMS Branch: - IT/CE Semester: - 3rd. 1. What does SQL stand for?

Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: nt

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

Lecture 8. Monday, September 29, 2014

1Z0-071 Exam Questions Demo Oracle. Exam Questions 1Z Oracle Database 12c SQL.

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

Transcription:

CS 327E Lecture 2 Shirley Cohen January 27, 2016

Agenda Announcements Homework for today Reading Quiz Concept Questions Homework for next time

Announcements Lecture slides and notes will be posted on the course web page after each class Quiz and participation scores will be posted on Canvas after each class Please use Piazza for questions and discussion topics that are of interest to other students Please email or come to office hours for discussing individual questions and concerns Almost everyone has successfully registered their clickers! Still missing a clicker for 5 students though: Patrick Fierro, David Martinez, Kathleen Morgan, Wei-Da Pan and Luis Sanchez

Homework for Today Chapter 3 from the Learning SQL book Exercises at end of Chapter 3

Quiz Question 1 Which clause is mandatory in an SQL query? A. WHERE B. FROM C. CHOOSE D. SELECT

Quiz Question 2 What keyword removes duplicate entries from the result set? A. DEDUP B. ALTER C. UNIQUE D. DISTINCT

Quiz Question 3 A JOIN is a mechanism for linking two tables. A. True B. False

Quiz Question 4 Which of the following clauses removes unwanted rows from a result set? A. FILTER B. HAVING C. WHERE D. VIEW

Quiz Question 5 Is the following query syntactically correct? SELECT cust_id, fed_id, address FROM customer ORDER BY fed_id, 1; A. No, since 1 does not correspond to a valid column B. No, since the ORDER BY syntax requires that columns be specified in schema order C. Yes mysql> describe customer; +--------------+------------------+ Field Type +--------------+------------------+ cust_id int(10) unsigned fed_id varchar(12) cust_type_cd enum('i','b') address varchar(30) city varchar(20) state varchar(20) postal_code varchar(10) +--------------+------------------+

Concept Question 1 We have a database for a retail store that keeps information about orders in a table called Order_Item. How can we produce a report of all the orders that is sorted by order number? A. SELECT * FROM Order_Item B. SELECT OrderNumber FROM Order_Item C. SELECT * FROM Order_Item ORDER BY OrderNumber DESC Order_Item (OrderNumber, SKU, Quantity, Price, ExtendedPrice) SELECT * FROM Order_Item D. SELECT * FROM Order_Item ORDER BY OrderNumber E. None of the above

Concept Question 2 We have the same Order_Item table. This time we want to generate a report that is sorted by price from highest to lowest and then by order number. A. SELECT * FROM Order_Item ORDER BY Price DESC, OrderNumber B. SELECT * FROM Order_Item ORDER BY Price ASC, OrderNumber Order_Item (OrderNumber, SKU, Quantity, Price, ExtendedPrice) SELECT * FROM Order_Item C. SELECT * FROM Order_Item ORDER BY Price, OrderNumber D. None of the above E. Not enough information

Concept Question 3 Suppose we have a product catalog database as illustrated by the diagram below. How can we retrieve the model number, speed, and hard drive capacity for all the PCs that cost less than $500? A. SELECT model, speed, hd FROM PC WHERE price < 500 B. SELECT p.model, pc.speed, pc.hd FROM Product p, PC pc WHERE p.model = pc.model AND price < 500 C. All of the above D. None of the above E. Not enough information

Concept Question 4 How can we find the model number, speed, and hard drive capacity of all PCs that have a 12x or 24x CD drive and that cost less than $600? A. SELECT model, speed, hd FROM PC WHERE price < 600 AND cd = '12x' OR cd = '24x B. SELECT model, speed, hd FROM PC WHERE price < 600 AND cd IN ('12x', '24x') C. SELECT model, speed, hd FROM PC WHERE price < 600 AND cd BETWEEN '12x' AND '24x' D. None of the above

Concept Question 5 We are building a database that tracks projects worked on by software development teams. Each project has one or more developers and they can be a lead, senior or junior developer on the project. Based on these requirements, suggest how to add some integrity checking to the Teams table. A. CONSTRAINT project_id_fk FOREIGN KEY project_id REFERENCES Projects(project_id) B. CONSTRAINT emp_id_fk FOREIGN KEY emp_id REFERENCES Employees(emp_id) C. CONSTRAINT role_ck CHECK(role IN ( L, S, J )) D. CONSTRAINT proj_emp_pk PRIMARY KEY (project_id, emp_id) E. All of the above create table Projects ( project_id INTEGER PRIMARY KEY, start_date DATE NOT NULL,... ) create table Employees ( emp_id INTEGER PRIMARY KEY, first_name VARCHAR(20), last_name VARCHAR(20),... ) create table Teams ( project_id INTEGER NOT NULL, emp_id INTEGER NOT NULL, role CHAR(1),... )

Homework for Next Time Chapter 4 from the Learning SQL book