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

Slides:



Advertisements
Similar presentations
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 David M. Kroenke’s Chapter Three: The Relational Model and Normalization.
Advertisements

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.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 COS 346 Day4.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 COS 346 Day5.
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 4-1 David M. Kroenke Database Processing Chapter 4 Database Design Using.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 COS 346 Day6.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 1-1 David M. Kroenke’s Chapter One: Introduction Part One Database Processing:
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 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 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.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 1-1 David M. Kroenke’s Database Processing: Fundamentals, Design, and.
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design and Implementation Chapter Two: Introduction to Structured Query Language.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
Structured Query Language
1 IT420: Database Management and Organization SQL: Structured Query Language 25 January 2006 Adina Crăiniceanu
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
David M. Kroenke’s Chapter One: Introduction Part Two Database Processing: Fundamentals, Design, and Implementation.
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.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 11-1 David M. Kroenke’s Chapter Eleven: Managing Databases with SQL Server.
BY SATHISH SQL Basic. Introduction The language Structured English Query Language (SEQUEL) was developed by IBM Corporation, Inc., to use Codd's model.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 6/1 Copyright © 2004 Please……. No Food Or Drink in the class.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall, modified by Dr. Lyn Mathis 4-1 David M. Kroenke’s Chapter Four: Database.
1 IT420: Database Management and Organization SQL part 3 7 February 2006 Adina Crăiniceanu
Introduction to Databases Three File Processing Systems DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 1-2.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
Structured Query Language
Database Queries aka SQL (pronounced “ sequel ” ).
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Four: Database Design Using Normalization 4-1 KROENKE.
DAVID M. KROENKE’S DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall 2-1 David M. Kroenke’s Chapter Two: Introduction to Structured Query.
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter Two: Introduction to Structured Query Language.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Four: Database Design Using Normalization.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Three: The Relational Model and Normalization.
1 Structured Query Language (SQL) Pertemuan 09 Matakuliah: F0712 / Lab MS Access Tahun: 2007.
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
David M. Kroenke and David J
CSIS 115 Database Design and Applications for Business
COS 346 Day 3 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
Database Processing: David M. Kroenke’s Chapter Four:
Database Design Using Normalization
SQL FUNDAMENTALS CDSE Days 2018.
Using SQL to Prepare Data for Analysis
Database Processing: David M. Kroenke’s Chapter One: Introduction
Database Processing: David M. Kroenke’s Chapter One: Introduction
Database Processing: David M. Kroenke’s Chapter Three:
Chapter 4 Summary Query.
Database Principles Constructed by Hanh Pham based on slides from: “Database Processing, Fundamentals, Design, and Implementation”, D. Kroenke, D. Auer,
Structured Query Language
Database Processing: David M. Kroenke’s Chapter Five:
David M. Kroenke and David J
Presentation transcript:

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

Agenda Chapter 2: Advanced SQL Next Quiz (Mon, 12/3) –Take online via Blackboard before 11:59pm –Must complete quiz once it is started –Topics: Normalization & Other DB Issues Homework 4 –Due Wednesday, November 28 th by START of class

Rest of Semester Agenda 11/28: Advanced SQL 12/3: Advanced SQL –Online quiz on normalization & other DB issues 12/5: Forms and Reports Workshop –Online quiz on SQL 12/10: Review Final Exam –Thursday, December 13 th, 8:30-10:30am –RB350 (Open Lab) A-3

Student Evaluations Available starting tomorrow Have until midnight on December 11 th (Reading Day) to complete If I get at least a 95% response rate, I will drop the lowest quiz grade for everyone!

Normalization Activity Blackboard In-Class Activities > Normalization A-5

Common Design Problems 4-6 Multivalue/multicolumn problem Inconsistent values Comments mixed with other data Storing data that change too frequently A single column that should be split Missing input mask Missing check constraint

The Multivalue, Multicolumn Problem The multivalue, multicolumn problem occurs when multiple values of an attribute are stored in more than one column: EMPLOYEE (EmployeeNumber, EmployeeLastName, EmployeeLastName, , Phone1, Phone2, Phone3) This is another form of a multivalued dependecy. Solution = like solution for multivalued dependencies, use a separate table to store the multiple values. 4-7 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

Inconsistent Values Inconsistent values occur when different users, or different data sources, use slightly different forms of the same data value: –Different codings: SKU_Description = 'Corn, Large Can' SKU_Description = 'Can, Corn, Large' SKU_Description = 'Large Can Corn‘ –Different spellings: Coffee, Cofee, Coffeee 4-8 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

Storing Data that Changes to Frequently What’s the problem? Why is it a problem? A-9

Comments Mixed with Other Data What problems does this cause?? A-10

A Single Column that Should be Split KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall A-11

Missing Input Mask Missing Check Constraint A-12

Blackboard - In-Class Activity 7 Multivalue/multicolumn problem Inconsistent values Comments mixed with other data Storing data that change too frequently A single column that should be split Missing input mask Missing check constraint 6-13

David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter Two: Introduction to Structured Query Language 2-14 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

Chapter Objectives SQL SELECT, FROM, WHERE, ORDER BY, GROUP BY, and HAVING clauses SQL DISTINCT, AND, OR, NOT, BETWEEN, LIKE, and IN keywords SUM, COUNT, MIN, MAX, and AVG functions Subqueries (we are going to skip these) Joining tables 2-15 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

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 2-16 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

Structured Query Language Structured Query Language (SQL) was developed by the IBM Corporation in the late 1970’s. 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 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

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 (;) KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

Cape-Codd Database [in Microsoft Access 2010] 2-19 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

Let’s Explore More SQL Open Cape-Codd Database KROENKE AND AUER - DATABASE PROCESSING, 11th Edition © 2010 Pearson Prentice Hall 6-20

SQL Built-In Functions I There are five SQL built-in functions: –Any field or * COUNT – counting rows returned –Number fields only SUM – Adding values in a number field AVG – Averaging values in a number field –Typically number fields MIN – Selecting the smallest value in a field MAX – Selecting the largest value in a field 2-21 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

SQL Built-In Functions Return the total of the ExtendedPrice field for all OrderNumber 3000 records (rows). Give the aggregate data returned meaningful labels 2-22 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

SQL Built-In Functions Return the total of the ExtendedPrice field for all OrderNumber 3000 records (rows). Give the aggregate data returned meaningful labels SELECTSUM(ExtendedPrice) ASOrder3000Sum FROMORDER_ITEM WHEREOrderNumber = 3000; 2-23 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

SQL Built-In Functions Return the total, average, minimum value, and maximum value of the ExtendedPrice field for all rows in the table. Give the aggregate data returned meaningful labels KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

SQL Built-In Functions Return the total, average, minimum value, and maximum value of the ExtendedPrice field for all rows in the table. Give the aggregate data returned meaningful labels. SELECTSUM(ExtendedPrice) AS OrderItemSum, AVG(ExtendedPrice) AS OrderItemAvg, MIN(ExtendedPrice) AS OrderItemMin, MAX(ExtendedPrice) AS OrderItemMax FROMORDER_ITEM; 2-25 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

SQL Built-In Functions Count the number of rows in the ORDER_ITEM table. Label the count column returned as NumberOfRows 2-26 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

SQL Built-In Functions Count the number of rows in the ORDER_ITEM table. Label the count column returned as NumberOfRows SELECTCOUNT(*) AS NumberOfRows FROMORDER_ITEM; 2-27 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

SQL Built-In Functions Count the number of unique departments in the SKU_DATA table. Give the aggregate data returned a meaningful label. SELECTCOUNT (DISTINCT Department) AS DeptCount FROMSKU_DATA; 2-28 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

Arithmetic in SELECT Statements SELECTQuantity * Price AS EP, ExtendedPrice FROMORDER_ITEM; What is this query going to return? 2-29 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

String Functions in SELECT Statements SELECTDISTINCT RTRIM (Buyer) + ' in ' + RTRIM (Department) AS Sponsor FROMSKU_DATA; What is this query going to return? 2-30 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall NOTE: This SQL statement uses SQL Server 2008 R2 syntax (works for Access as well) —other DBMS products use different concatenation and character string operators.

The SQL Keyword GROUP BY SELECTDepartment, Buyer, COUNT(*) AS Dept_Buyer_SKU_Count FROMSKU_DATA GROUP BY Department, Buyer; What is this query going to return? 2-31 KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall