CSIS 115 Database Design and Applications for Business

Slides:



Advertisements
Similar presentations
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 1-1 COS 346 Day 2.
Advertisements

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 2-1 David M. Kroenke’s Chapter Two: Introduction to Structured Query.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 9 Structured Query Language.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 1-1 COS 346 Day 2.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 2-1 David M. Kroenke’s Chapter Two: Introduction to Structured Query.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 17.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 2-1 David M. Kroenke’s Chapter Two: Introduction to Structured Query.
Structured Query Language Part I Chapter Three CIS 218.
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
By Mary Anne Poatsy, Keith Mulbery, Eric Cameron, Jason Davidson, Rebecca Lawson, Linda Lau, Jerri Williams Chapter 10 Using Macros and SQL in Access 1.
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design and Implementation Chapter Two: Introduction to Structured Query Language.
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
SQL for Data Retrieval. Save your SQL Scripts When working with SQL Management Studio, you should keep saving your scripts as a.sql file to somewhere.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
SQL Operations Aggregate Functions Having Clause Database Access Layer A2 Teacher Up skilling LECTURE 5.
Structured Query Language
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Chapter 10 Queries and Updating Part C. SQL Copyright 2005 Radian Publishing Co.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter Two: Introduction to Structured Query Language.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
STRUCTURED QUERY LANGUAGE SQL-II IST 210 Organization of Data IST210 1.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL for Data Retrieval. Save your SQL Scripts When working with SQL Management Studio, you should keep saving your scripts as a.sql file to somewhere.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Aliya Farheen October 29,2015.
Structured Query Language
Database Queries aka SQL (pronounced “ sequel ” ).
DAVID M. KROENKE’S DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall 2-1 David M. Kroenke’s Chapter Two: Introduction to Structured Query.
+ Complex SQL Week 9. + Today’s Objectives TOP GROUP BY JOIN Inner vs. Outer Right vs. Left.
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
WEEK# 12 Haifa Abulaiha November 02,
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
Fall Lab 131 CS105 Lab 13 – Logical Operator Precedence and Joining Tables Announcements: MP 3 released Friday, 11/20 Honors project due: Tuesday,
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter Two: Introduction to Structured Query Language.
Query Data From Database  We use the SELECT statement to retrieve information from the database. SELECT attribute/s FROM table/s WHERE (condition)
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Three: The Relational Model and Normalization.
2 Delete and update  Delete a record  Update a record DELETE FROM vet_appt WHERE vet_appt_id = 3; UPDATE animal SET’ gender = “MS” WHERE animal_id =
Structured Query Language SQL-II IST 210 Organization of Data IST2101.
1 Structured Query Language (SQL) Pertemuan 09 Matakuliah: F0712 / Lab MS Access Tahun: 2007.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
CSIS 115 Database Design and Applications for Business Dr. Meg Fryling “Dr. Meg” Fall #csis115 © 2012 Meg Fryling.
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
Chapter 5 Introduction to SQL.
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
Writing Basic SQL SELECT Statements
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
 2012 Pearson Education, Inc. All rights reserved.
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
The University of Texas – Pan American
David M. Kroenke and David J
CIS16 Application Programming with Visual Basic
Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
Database Principles Constructed by Hanh Pham based on slides from: “Database Processing, Fundamentals, Design, and Implementation”, D. Kroenke, D. Auer,
Access: SQL Participation Project
Structured Query Language
Introduction To Structured Query Language (SQL)
Presentation transcript:

CSIS 115 Database Design and Applications for Business Dr. Meg Fryling “Dr. Meg” Fall 2012 @SienaDrMeg #csis115

Agenda Questions? Assignments Review Chapter 2 - SQL Basics “Fun” with iClicker Chapter 2 - SQL Basics Continued

Homework Project Part I Finish Chapter 3 (100-105 only) Was due at the start of class today Finish Chapter 3 (100-105 only) Finish Chapter 5 Reminder: Quiz 1 will be Mon, 9/24 Closed book but you may have a 8.5x11 handwritten “cheat sheet”. Must use your own and turn in with quiz.

Let’s do some review from last week Get those clickers ready!

The industry standard supported by all major DBMS that allows data to be selected, added, updated, and deleted from a relational database is… A) Sequential Query Language (SQL) B) Structured Question Language (SQL) C) Structured Query Language (SQL) D) Relational Question Language (RQL) E) Relational Query Language (RQL)

Which elements are required in an SQL statement SELECT FROM WHERE SELECT and FROM SELECT, FROM, and WHERE Answer: D

In addition to being a data sublanguage, SQL is also a programming language, like Java or C# A) True B) False Answer: FALSE KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

The SQL keyword SELECT is used to specify the __________ to be listed in the query results. A) Columns B) Rows C) Records D) Tuples E) None of the above Answer: A KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

A column is also referred to as a field or an attribute A) True B) False Answer: A KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

Add ORDER BY Update the query below so it sorts the records by OrderNumber and then by Price SELECT * FROM ORDER_ITEM ORDER BY OrderNumber; Last time we ended with this query

Sorting the Results – ORDER BY SELECT * FROM ORDER_ITEM ORDER BY OrderNumber, Price; KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

Which order are the results sorting in? Ascending Descending Sort Order Default Which order are the results sorting in? Ascending Descending Answer: A

Sort Order: Ascending and Descending SELECT * FROM ORDER_ITEM ORDER BY Price DESC, OrderNumber ASC; NOTE: The default sort order is ASC – does not have to be specified. KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

SQL for Data Retrieval: Logical Operators Multiple matching criteria (conditions) may be specified using… AND Representing an intersection of the data sets OR Representing a union of the data sets

Write a Query Selects all columns from the SKU_DATA table Only include rows for the Water Sports department where the buyer is Nancy Meyers

WHERE Clause Options - AND SELECT * FROM SKU_DATA WHERE Department = 'Water Sports' AND Buyer = 'Nancy Meyers'; KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

Write a Query Selects all columns from the SKU_DATA table Only include rows that are associated with the Camping or the Climbing department

WHERE Clause Options - OR SELECT * FROM SKU_DATA WHERE Department = 'Camping' OR Department = 'Climbing'; KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

How many rows will this query return? SELECT * FROM SKU_DATA WHERE Department = 'Water Sports' AND Buyer = 'Nancy Meyers'; Answer: 2 Just look at data in SKU_DATA table first to answer this question?

How many rows will this query return? SELECT * FROM SKU_DATA WHERE Department = 'Camping' OR Department = 'Climbing'; Answer: 4 Just look at data in SKU_DATA table first to answer this question?

Write a Query That will return all columns from the ORDER_ITEM table Only include records with an extended price greater than or equal to 100 and less than or equal to 200 Only include records for SKU 101100 or SKU 101200 Hint: You will need to use both AND and OR in the WHERE clause

Using both OR and AND SELECT * FROM ORDER_ITEM WHERE ExtendedPrice >= 100 AND ExtendedPrice <= 200 AND SKU = 101100 OR SKU = 101200; Does this return what you would expect?

Remember operator precedence? 3 + 4 × 5 = 23 vs (3 + 4) × 5 = 35 KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

Excel OR() and AND() Functions Recall CSIS114 BI-OLAP Lab =IF(OR(A3<62,C3="snow",C3="rain",B3>70%,AND(D3="Monday",OR(E4="Average",E4="Bad"))),"no","yes")

Using both OR and AND SELECT * FROM ORDER_ITEM WHERE ExtendedPrice >= 100 AND ExtendedPrice <= 200 AND SKU = 101100 OR SKU = 101200; How do you think you can “fix” this query?

Using both OR and AND SELECT * FROM ORDER_ITEM WHERE ExtendedPrice >= 100 AND ExtendedPrice <= 200 AND (SKU = 101100 OR SKU = 101200);

Gotcha When using both OR & AND clauses be sure to use () to clarify what criteria belongs together If not you may get unexpected results! KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall

SQL for Data Retrieval: Inclusion/Exclusion SQL provides a IN/NOT IN statements that allows a user to specify all valid values on one line! SWEET SELECT FieldName FROM TABLE WHERE FieldName IN (X,Y,Z); SELECT FieldName FROM TABLE WHERE FieldName = X OR FieldName = Y OR FieldName = Z; You can use this instead of _______________

SQL for Data Retrieval: The Logical NOT Operator Any criteria statement may be preceded by a NOT operator which is to say that all information will be shown except that information matching the specified criteria SELECT FieldName FROM TABLE WHERE FieldName NOT IN (X, Y, Z);

WHERE Clause Options - IN Update query below so it uses IN clause to return same results SELECT * FROM ORDER_ITEM WHERE ExtendedPrice >= 100 AND ExtendedPrice <= 200 AND (SKU = 101100 OR SKU = 101200);

WHERE Clause Options - IN SELECT * FROM ORDER_ITEM WHERE ExtendedPrice >= 100 AND ExtendedPrice <= 200 AND SKU IN(101100, 101200); Wow, that sure looks cleaner! What if we wanted to return all SKU records that were NOT 101100 or 101200 but had an extended price between 100 and 200?

WHERE Clause Options – NOT IN SELECT * FROM ORDER_ITEM WHERE ExtendedPrice >= 100 AND ExtendedPrice <= 200 AND SKU NOT IN(101100, 101200);

SQL for Data Retrieval: Finding Data in a Range of Values SQL provides a BETWEEN statement that allows a user to specify a minimum and maximum value on one line! SUPER SWEET Note: Will include the minimum and maximum value in the results SELECT FieldName FROM TABLE WHERE FieldName BETWEEN X AND Y;

SQL for Data Retrieval: Finding Data in a Range of Values Update query below so it uses BETWEEN clause to return same results SELECT * FROM ORDER_ITEM WHERE ExtendedPrice >= 100 AND ExtendedPrice <= 200 AND SKU IN(101100, 101200);

WHERE Clause Options – BETWEEN SELECT * FROM ORDER_ITEM WHERE ExtendedPrice BETWEEN 100 AND 200 AND SKU IN(101100, 101200); Huh, that’s awesome!

In-Class Activity Part III SQL Basics In-Class Activity Part III