Database Principles Constructed by Hanh Pham based on slides from: “Database Processing, Fundamentals, Design, and Implementation”, D. Kroenke, D. Auer,

Slides:



Advertisements
Similar presentations
Introduction to Structured Query Language (SQL)
Advertisements

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 2 Structured Query Language.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 1-1 COS 346 Day 2.
Introduction to Structured Query Language (SQL)
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 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.
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
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 and David J. Auer Database Processing: Fundamentals, Design and Implementation Chapter Two: Introduction to Structured Query Language.
Chapter 3: SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Structured Query Language
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
1 IT420: Database Management and Organization SQL: Structured Query Language 25 January 2006 Adina Crăiniceanu
Rationale Aspiring Database Developers should be able to efficiently query and maintain databases. This module will help students learn the Structured.
Chapter 5 Lecture 2. Principles of Information Systems2 Objectives Understand Data definition language (DDL) and data dictionary Learn about popular DBMSs.
Introduction to SQL Yong Choi School of Business CSU, Bakersfield.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
DBS201: Introduction to Database Design and SQL
CIS 103 — Applied Computer Technology Last Edited: September 17, 2010 by C.Herbert Using Database Management Systems.
Introduction to databases and SQL. What is a database?  A database is an organized way of holding together pieces of information  A database refers.
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter Two: Introduction to Structured Query Language.
Fundamentals, Design, and Implementation, 9/e CPE 481 Database Processing Chapter 6 Structured Query Language (SQL) Instructor:Suthep Madarasmi, Ph.D.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
5-1 McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 6/1 Copyright © 2004 Please……. No Food Or Drink in the class.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
SQL. คำสั่ง SQL SQL stands for Structured Query Language is a standard language for accessing and manipulating databases.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
DAVID M. KROENKE’S DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall 2-1 David M. Kroenke’s Chapter Two: Introduction to Structured Query.
IS6146 Databases for Management Information Systems Lecture 1: Introduction to IS6146 Rob Gleasure robgleasure.com.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 5: SQL I Rob Gleasure robgleasure.com.
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter Two: Introduction to Structured Query Language.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
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.
Chapter Seven: SQL for Database Construction and Application Processing.
COS 346 Day 3 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition
Web Systems & Technologies
CHAPTER 7 DATABASE ACCESS THROUGH WEB
“Introduction To Database and SQL”
CSIS 115 Database Design and Applications for Business
Oracle & SQL Introduction
CSIS 115 Database Design and Applications for Business
Introduction to Structured Query Language(SQL)
David M. Kroenke and David J
Fundamentals & Ethics of Information Systems IS 201
COS 346 Day 3 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition
Fundamentals of Information Systems
Using SQL to Prepare Data for Analysis
Database Management System (DBMS)
Database Processing: David M. Kroenke’s Chapter One: Introduction
part 1 with pages 1-32 and part 2 with pages 33-69
Database Processing: David M. Kroenke’s Chapter One: Introduction
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Introduction to Databases
Introduction To Structured Query Language (SQL)
Structured Query Language
Presentation transcript:

Database Principles Constructed by Hanh Pham based on slides from: “Database Processing, Fundamentals, Design, and Implementation”, D. Kroenke, D. Auer, Prentice Hall “Database Principles: Fundamentals of Design, Implementation, and Management”, C. Coronel, S. Morris, P.Rob Introduction to SQL

Outlines Extracted data sets in business intelligence (BI) systems Ad-hoc queries in business intelligence (BI) systems History and significance of structured query language (SQL) SQL SELECT/FROM/WHERE framework SQL queries to retrieve data from a single table SELECT, FROM, WHERE, ORDER BY, GROUP BY, and HAVING clauses DISTINCT, AND, OR, NOT, BETWEEN, LIKE, and IN keywords

Business Intelligence (BI) Systems Business intelligence (BI) systems are information systems that assist managers and other professionals: Assessment Analysis Planning Control

Ad-Hoc Queries Ad-hoc queries: Questions that can be answered using database data Example: “How many customers in Portland, Oregon, bought our green baseball cap?” Created by the user as needed, instead of programmed into an application Common in business

Structured Query Language Structured Query Language (SQL) was developed by the IBM Corporation in the late 1970’s. SQL was endorsed as a U.S. national standard by the American National Standards Institute (ANSI) in 1992 [SQL-92]. Newer versions exist, and they incorporate XML and some object-oriented concepts.

SQL As a Data Sublanguage SQL is not a full featured programming language. C, C#, Java SQL is a data sublanguage for creating and processing database data and metadata. SQL is ubiquitous in enterprise-class DBMS products. SQL programming is a critical skill.

SQL DDL, DML, and SQL/PSM SQL statements can be divided into three categories: Data definition language (DDL) statements Used for creating tables, relationships, and other structures Covered in Chapter 7 Data manipulation language (DML) statements Used for queries and data modification Covered in this chapter (Chapter 2) SQL/Persistent Stored Modules (SQL/PSM) statements Add procedural programming capabilities Variables Control-of-flow statements

EXAMPLE: Cape Codd Outdoor Sports Cape Codd Outdoor Sports is a fictitious company based on an actual outdoor retail equipment vendor. Cape Codd Outdoor Sports: Has 15 retail stores in the United States and Canada. Has an online Internet store. Has a (postal) mail order department. All retail sales are recorded in an Oracle database.

Cape Codd Retail Sales Structure

Cape Codd Retail Sales Data Extraction The Cape Codd marketing department needs an analysis of in-store sales. The entire database is not needed for this, only an extraction of retail sales data. The data is extracted by the IS department from the operational database into a separate, off-line database for use by the marketing department. Three tables are used: RETAIL_ORDER, ORDER_ITEM, and SKU_DATA (SKU = Stock Keeping Unit). The extracted data is converted as necessary: Into a different DBMS—Microsoft SQL Server Into different columns—OrderDate becomes OrderMonth and OrderYear.

Extracted Retail Sales Data Format

Retail Sales Extract Tables [in Microsoft Access]

The SQL SELECT Statement The fundamental framework for an SQL query is the SQL SELECT statement. SELECT {ColumnName(s)} FROM {TableName(s)} WHERE {Condition(s)} All SQL statements end with a semi-colon (;).

Specific Columns on One Table SELECT Department, Buyer FROM SKU_DATA;

Specifying Column Order SELECT Buyer, Department FROM SKU_DATA;

The DISTINCT Keyword SELECT DISTINCT Buyer, Department FROM SKU_DATA;

Selecting All Columns: The Asterisk (*) Wildcard Character FROM SKU_DATA;

Specific Rows from One Table SELECT * FROM SKU_DATA WHERE Department = 'Water Sports'; NOTE: SQL wants a plain ASCII single quote: ' NOT ‘ !

Specific Columns and Rows from One Table SELECT SKU_Description, Buyer FROM SKU_DATA WHERE Department = 'Climbing';

Sorting the Results—ORDER BY SELECT * FROM ORDER_ITEM ORDER BY OrderNumber, Price;

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.

WHERE Clause Options—AND SELECT * FROM SKU_DATA WHERE Department = 'Water Sports' AND Buyer = 'Nancy Meyers';

WHERE Clause Options—OR SELECT * FROM SKU_DATA WHERE Department = 'Camping' OR Department = 'Climbing';

WHERE Clause Options—IN SELECT * FROM SKU_DATA WHERE Buyer IN ('Nancy Meyers', 'Cindy Lo', 'Jerry Martin');

WHERE Clause Options—NOT IN SELECT * FROM SKU_DATA WHERE Buyer NOT IN ('Nancy Meyers', 'Cindy Lo', 'Jerry Martin');

WHERE Clause Options—Ranges with BETWEEN SELECT * FROM ORDER_ITEM WHERE ExtendedPrice BETWEEN 100 AND 200;

WHERE Clause Options—Ranges with Math Symbols SELECT * FROM ORDER_ITEM WHERE ExtendedPrice >= 100 AND ExtendedPrice <= 200;