Exam 2 Exam 2 Study Guide is posted on the Course Site

Slides:



Advertisements
Similar presentations
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
Advertisements

INFORMATION TECHNOLOGY IN BUSINESS AND SOCIETY SESSION 16 – SQL SEAN J. TAYLOR.
Agenda Common terms used in the software of data warehousing and what they mean. Difference between a database and a data warehouse - the difference in.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
CSC 2720 Building Web Applications Database and SQL.
SQL 1: GETTING INFORMATION OUT OF A DATABASE MIS2502 Data Analytics.
1 Data Warehouses BUAD/American University Data Warehouses.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
MIS2502: Data Analytics SQL – Getting Information Out of a Database David Schuff
Tables and Constraints Oracle PL/SQL. Datatypes The SQL Data Definition Language Commands (or DDL) enable us to create, modify and remove database data.
Fox MIS Spring 2011 Database Week 6 ERD and SQL Exercise.
CHAPTER 9 SQL อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Advanced Adhoc Reporting 2010 Visions Conference July 28, 2010.
MIS2502: Data Analytics SQL – Putting Information Into a Database David Schuff
MIS2502: Data Analytics SQL – Getting Information Out of a Database.
A Guide to MySQL 6. 2 Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT command.
Exam 2 Review: SQL In, Dimensional Modeling, Pivot Tables, ETL Describe data cube elements Understand facts, dimensions, granularity Create/read a Star.
SQL: Structured Query Language It enables to create and operate on relational databases, which are sets of related information stored in tables. It is.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
 MySQL  DDL ◦ Create ◦ Alter  DML ◦ Insert ◦ Select ◦ Update ◦ Delete  DDL(again) ◦ Drop ◦ Truncate.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
N5 Databases Notes Information Systems Design & Development: Structures and links.
Fundamental of Database Systems
CompSci 280 S Introduction to Software Development
How to: SQL By: Sam Loch.
SQL Query Getting to the data ……..
CIS 336 AID Your Dreams Our Mission/cis336aid.com
Relational Database Design
Insert, Update and the rest…
MIS2502: Data Analytics SQL – Putting Information Into a Database
PL/SQL LANGUAGE MULITPLE CHOICE QUESTION SET-1
Structured Query Language – The Basics
MySQL Joins MySQL joins are used to combine rows from two or more tables. Different SQL JOINs INNER JOIN: Returns all rows when there is at least one match.
Data Warehouse.
Data Visualization Data visualization principles. Tell a story
MIS2502: Data Analytics SQL – Putting Information Into a Database
CIS 336 Competitive Success/snaptutorial.com
CIS 336 Education for Service-- snaptutorial.com.
CIS 336 Teaching Effectively-- snaptutorial.com
MIS2502: Data Analytics SQL – Getting Information Out of a Database
Data warehouse Design Using Oracle
MIS2502: Data Analytics SQL – Putting Information Into a Database
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
MIS2502: Review for Exam 1 JaeHwuen Jung
MIS2502: Data Analytics SQL – Getting Information Out of a Database
MIS2502: Data Analytics SQL – Getting Information Out of a Database Part 2: Advanced Queries Aaron Zhi Cheng
Introduction To Structured Query Language (SQL)
MIS2502: Data Analytics Dimensional Data Modeling
Database systems Lecture 3 – SQL + CRUD
MIS2502: Data Analytics SQL – Putting Information Into a Database
TITLE OF PRESENTATION PRESENTER.
MIS2502: Review for Exam 1 Aaron Zhi Cheng
MIS2502: Data Analytics SQL – Putting Information Into a Database
CS122 Using Relational Databases and SQL
Structured Query Language – The Fundamentals
MIS2502: Data Analytics Dimensional Data Modeling
MIS2502: Data Analytics SQL – Putting Information Into a Database
Lecture 3 Finishing SQL
Introduction To Structured Query Language (SQL)
CS1222 Using Relational Databases and SQL
Data Definition Language
Nagendra Vemulapalli Exam2 Overview Nagendra Vemulapalli
MIS2502: Data Analytics SQL 4– Putting Information Into a Database
MIS2502: Data Analytics SQL – Getting Information Out of a Database Part 1: Basic Queries Aaron Zhi Cheng
MIS2502: Data Analytics SQL – Getting Information Out of a Database Part 2: Advanced Queries Zhe (Joe) Deng
CS122 Using Relational Databases and SQL
Presentation transcript:

Exam 2 Exam 2 Study Guide is posted on the Course Site The exam is on Friday, 11/2/2018 during class time. I will hold an exam review session on Wednesday, 10/31. ITA Nathaly will hold additional office hours on Thursday, 11/1, 1:00-3:00pm at Alter 604A.

MIS2502: Review for Exam 2 Aaron Zhi Cheng acheng@temple.edu http://community.mis.temple.edu/zcheng

Please arrive 5 minutes early! Overview Date/Time: Friday, Nov 2, in class (50 minutes) Place: Regular classroom Please arrive 5 minutes early! Multiple-choice and short-answer questions Closed-book, closed-note No computer

Check the Exam 2 Study Guide Coverage Check the Exam 2 Study Guide Not every item on this list may be on the exam, and there may be items on the exam not on this list. **Advanced Analytics and R will be covered in Exam 3.

SQL Joins Used to combine two or more tables, based on the common fields between them. Suppose we have…. MyDB.Order MyDB.Customer OrderID CustomerID OrderDate Amount 10308 2 1996-09-18 100 10309 1 1996-09-19 10 10310 1996-09-20 63 CustomerID LastName FirstName Country 1 Futterkiste Alfreds Germany 2 Trujillo Ana US 3 Moreno Antonio Mexico

A Correct, Simple Join SELECT * FROM MyDB.Order, MyDB.Customer WHERE Order.CustomerID=Customer.CustomerID; MyDB.Order MyDB.Customer OrderID CustomerID OrderDate Amount 10308 2 1996-09-18 100 10309 1 1996-09-19 10 10310 1996-09-20 63 CustomerID LastName FirstName Country 1 Futterkiste Alfreds Germany 2 Trujillo Ana US 3 Moreno Antonio Mexico Order. OrderID CustomerID OrderDate Amount Customer. LastName FirstName Country 10308 2 1996-09-18 100 Trujillo Ana US 10309 1 1996-09-19 10 Futterkiste Alfreds Germany 10310 1996-09-20 63

What If We Don’t Have the WHERE condition? It will fetch every possible combination (pair) of records from the two tables SELECT * FROM MyDB.Order, MyDB.Customer WHERE Order.CustomerID=Customer.CustomerID; MyDB.Order MyDB.Customer OrderID CustomerID OrderDate Amount 10308 2 1996-09-18 100 10309 1 1996-09-19 10 10310 1996-09-20 63 CustomerID LastName FirstName Country 1 Futterkiste Alfreds Germany 2 Trujillo Ana US 3 Moreno Antonio Mexico 3×3 = 9 rows Order. OrderID CustomerID OrderDate Amount Customer. LastName FirstName Country 10308 2 1996-09-18 100 1 Futterkiste Alfreds Germany Trujillo Ana US 3 Moreno Antonio Mexico 10309 1996-09-19 10 10310 1996-09-20 63

More Variations to Join Step 1: We start with a simple join SELECT * FROM MyDB.Order, MyDB.Customer WHERE Order.CustomerID=Customer.CustomerID; Step 2: We then end up with - SELECT Customer.Country, SUM(Order.Amount) WHERE Order.CustomerID=Customer.CustomerID GROUP BY Customer.Country; Q: What is the total order amount by country? Order. OrderID CustomerID OrderDate Amount Customer. LastName FirstName Country 10308 2 1996-09-18 100 Trujillo Ana US 10309 1 1996-09-19 10 Futterkiste Alfreds Germany 10310 1996-09-20 63 Customer. Country SUM(Order.Amount) US 100 Germany 73

SQL (Subselects) Subselect query can return One single value (one column, one row) A temporary table (one or multiple columns, one or multiple rows)

One single value: Used With Comparison Operators SELECT column_name1 FROM schema_name.table_name1 WHERE column_name2 comparison_operator (SELECT column_name3 FROM schema_name.table_name2 WHERE condition); Treated as a single value comparison_operator could be equality operators such as =, >, <, >=, <=, <>.

Subselect as One Single Value: Example 1 MyDB.Order Step 1. We start by write the subselect query that returns the average order amount: SELECT AVG(Amount) FROM MyDB.Order Step 2. We treat the subselect query as a single value: SELECT OrderID, Amount FROM MyDB.Order WHERE Amount < (SELECT AVG(Amount) FROM MyDB.Order); Q: What are the order IDs with order amount below average? OrderID CustomerID OrderDate Amount 10308 2 1996-09-18 100 10309 1 1996-09-19 10 10310 1996-09-20 63 Amount 57.6667 OrderID Amount 10309 10

Subselect as One Single Value: Example 2 Q: Which German customer placed the order(s) with the highest order amount? MyDB.Order MyDB.Customer OrderID CustomerID OrderDate Amount 10308 2 1996-09-18 100 10309 1 1996-09-19 10 10310 1996-09-20 63 CustomerID LastName FirstName Country 1 Futterkiste Alfreds Germany 2 Trujillo Ana US 3 Moreno Antonio Mexico SELECT * FROM MyDB.Order, MyDB.Customer WHERE Order.CustomerID=Customer.CustomerID; Recall the simple join query… Order. OrderID CustomerID OrderDate Amount Customer. LastName FirstName Country 10308 2 1996-09-18 100 Trujillo Ana US 10309 1 1996-09-19 10 Futterkiste Alfreds Germany 10310 1996-09-20 63

Subselect as One Single Value: Example 2 Q: Which German customer placed the order(s) with the highest order amount? Step 1. We start by write the subselect query that returns the highest order amount for German customers: SELECT MAX(Order.Amount) FROM MyDB.Order, MyDB.Customer WHERE Order.CustomerID=Customer.CustomerID AND Customer.Country=‘Germany’; Step 2. We treat the subselect query as a single value: SELECT Customer.LastName, Customer.FirstName, Order.Amount AND Customer.Country=‘Germany’ AND Amount= (SELECT MAX(Order.Amount) AND Customer.Country=‘Germany’); Amount 63 LastName FirstName Amount Futterkiste Alfreds 63

As a temporary table SELECT column_name(s) FROM (SELECT column_name(s) FROM schema_name.table_name2 WHERE condition) ; Treated as a table

Subselect as a temporary table Q: How many countries are there in the customer table? MyDB.Customer CustomerID LastName FirstName Country 1 Futterkiste Alfreds Germany 2 Trujillo Ana US 3 Moreno Antonio Mexico 4 Dean Michael

Subselect as a temporary table Q: How many countries are there in the customer table? Step 1. We start by writing the subselect query that returns the distinct countries: SELECT DISTINCT Country FROM MyDB.Customer; Country Germany US Mexico Step 2. We treat the subselect query as a temporary table: SELECT COUNT(*) FROM (SELECT DISTINCT Country FROM MyDB.Customer); COUNT(*) 3

SQL (CREATE TABLE) CREATE TABLE schema_name.table_name ( columnName1 datatype [NULL][NOT NULL], columnName2 datatype [NULL][NOT NULL], PRIMARY KEY (KeyName); If there is no foreign key: CREATE TABLE schema_name.table_name ( columnName1 datatype [NULL][NOT NULL], columnName2 datatype [NULL][NOT NULL], PRIMARY KEY (KeyName), FOREIGN KEY (ForeignKeyName) REFERENCES schema_name.reference_table_name(ReferenceKeyName)); If there is foreign key: When to use NOT NULL?

DROP TABLE, ALTER TABLE DROP TABLE schema_name.table_name; Drops a table DROP TABLE schema_name.table_name; ALTER TABLE schema_name.table_name ADD COLUMN column_name datatype [NULL][NOT NULL]; or ALTER TABLE schema_name.table_name DROP COLUMN column_name; ALTER TABLE schema_name.table_name CHANGE COLUMN old_column_name new_column_name datatype [NULL][NOT NULL]; Adds a column to the table Removes a column from the table Changes a column in the table

INSERT INTO, UPDATE, DELETE FROM To insert a record into a table: INSERT INTO schema_name.table_name (columnName1, columnName2, columnName3) VALUES (value1, value2, value3); To change data in a row: UPDATE schema_name.table_name SET columnName1=value1, columnName2=value2 WHERE condition; To delete a row from a table: DELETE FROM schema_name.table_name WHERE condition; What to use in the WHERE condition? How about this WHERE condition?

Data Types Q: What does DECIMAL(4, 1) indicate? Description Examples INT Integer 3, -10 DECIMAL(p,s) Decimal. Example: decimal(5,2) is a number that has 3 digits before decimal and 2 digits after decimal 3.23, 3.14159 VARCHAR(n) String (numbers and letters) with maximum length n 'Hello, I like pizza, MySQL!' DATETIME, DATE Date/Time, or just Date '2011-09-01 17:35:00', '2011-04-12' BOOLEAN Boolean value 0 or 1 Q: What does DECIMAL(4, 1) indicate? A: The value cannot go beyond -999.9~ 999.9

ETL and Assignment 4 Extract data from the operational data store Transform data into an analysis-ready format Load it into the analytical data store What is it? Why is it important? Data consistency Data quality Explain the purpose of each component (Extract, Transform, Load) Excel Basics: Absolute and relative references Excel functions LEN, VLOOKUP and CONCATENATE

Dimensional Data Modeling Data warehouse vs data mart vs data cube Data Cube Star schema Kimball’s four step process for dimensional data modeling “non-volatility” of data cubes 1. Choose the business process 2. Decide on the level of granularity 3. Identify the fact 4. Identify the dimensions

Pivot Tables Given a question about a set of data, be able to identify the fields required to create a pivot table Identify which fields are assigned as VALUES and which ones are assigned as ROWS Identify the correct function for aggregation: i.e., SUM, COUNT, AVERAGE, etc. Understand how to use sorting and label filter

Pivot Tables vs. data cubes Equivalent to “dimensions” in a data cube Equivalent to “measured facts” in a data cube

Data Visualization Data visualization principles. Tell a story Graphical integrity (lie factor) Minimize graphical complexity (data ink, chartjunk, Moiré effects )

Issues with this chart? Issues: Tell a Story Graphical Integrity Example from ICA #6.1 - Chart #3: Issues: Tell a Story Vertical axis isn’t labeled. We don’t know the units Because there are many states to compare, horizontal lines may be helpful Graphical Integrity The 3D chart makes it difficult to compare sizes The cone-shaped bars make it even harder to compare sizes Graphical Complexity The 3D chart requires more ink (Chartjunk) The number labels are unnecessary

Good Luck!