MIS2502: Review for Exam 1 JaeHwuen Jung jaejung@temple.edu http://community.mis.temple.edu/jaejung.

Slides:



Advertisements
Similar presentations
More Diagramming & Practice with Relationship Modeling
Advertisements

Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
A Guide to SQL, Seventh Edition. Objectives Retrieve data from a database using SQL commands Use compound conditions Use computed columns Use the SQL.
MIS2502: Data Analytics Relational Data Modeling
Computer Science 101 Web Access to Databases SQL – Extended Form.
Chapter 3 Single-Table Queries
MIS2502: Data Analytics Coverting ERD into a DB Schema David Schuff
SQL 1: GETTING INFORMATION OUT OF A DATABASE MIS2502 Data Analytics.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
Concepts of Database Management Seventh Edition
MIS2502: Data Analytics SQL – Getting Information Out of a Database David Schuff
MIS2502: Data Analytics The Information Architecture of an Organization.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Data Analytics SQL – Putting Information Into a Database David Schuff
RELATIONAL DATA MODELING MIS2502 Data Analytics. What is a model? Representation of something in the real world.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
MIS2502: Data Analytics SQL – Getting Information Out of a Database.
MIS2502: Data Analytics Relational Data Modeling David Schuff
MIDTERM REVIEW IST 210 Organization of Data IST210 1.
Southern Methodist University CSE CSE 2337 Introduction to Data Management Chapter 2.
Jaclyn Hansberry MIS2502: Data Analytics The Things You Can Do With Data The Information Architecture of an Organization Jaclyn.
Order Database – ER Diagram
How to: SQL By: Sam Loch.
A Guide to SQL, Eighth Edition
Order Database – ER Diagram
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
MIS2502: Data Analytics SQL – Putting Information Into a Database
MIS2502: Data Analytics Relational Data Modeling
 2012 Pearson Education, Inc. All rights reserved.
Order Database – ER Diagram
Order Database – ER Diagram
MIS5101: Business Intelligence Relational Data Modeling
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
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
MIS2502: Data Analytics SQL – Getting Information Out of a Database
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Data Analytics SQL – Putting Information Into a Database
MIS2502: Data Analytics SQL – Getting Information Out of a Database
MIS2502: Data Analytics Converting ERDs to Schemas
MIS2502: Data Analytics SQL – Getting Information Out of a Database Part 2: Advanced Queries Aaron Zhi Cheng
MIS2502: Data Analytics The Information Architecture of an Organization David Schuff
MIS2502: Data Analytics The Information Architecture of an Organization Acknowledgement: David Schuff.
MIS2502: Data Analytics The Information Architecture of an Organization Aaron Zhi Cheng Acknowledgement:
Prof: Dr. Shu-Ching Chen TA: Haiman Tian
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Data Analytics Dimensional Data Modeling
Schema Template Employee Office EmployeeOffice EmployeeID OfficeID
Order Database – ER Diagram
Exam 2 Exam 2 Study Guide is posted on the Course Site
MIS2502: Data Analytics SQL – Putting Information Into a Database
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Review for Exam 1 Aaron Zhi Cheng
MIS2502: Data Analytics SQL – Putting Information Into a Database
MIS2502: Data Analytics Dimensional Data Modeling
Order Database – ER Diagram
MIS2502: Data Analytics SQL – Putting Information Into a Database
M1G Introduction to Database Development
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Data Analytics SQL 4– Putting Information Into a Database
MIS2502: Data Analytics Relational Data Modeling 2
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
MIS2502: Data Analytics Relational Data Modeling 3
Presentation transcript:

MIS2502: Review for Exam 1 JaeHwuen Jung jaejung@temple.edu http://community.mis.temple.edu/jaejung

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

Check the Exam 1 Study Guide Coverage Check the Exam 1 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.

Transactional database vs. Analytical data store The Things You Can Do With Data/ The Information Architecture of an Organization Data vs. information Transaction Business transaction Database transaction Transactional database vs. Analytical data store Characteristics, goals, relationship

The Information Architecture of an Organization Data entry Transactional Database Data extraction Analytical Data Store Data analysis Stores real-time transactional data Stores historical transactional and summary data Called OLTP: Online transaction processing Called OLAP: Online analytical processing

Comparing Transactional and Analytical Data Stores Transactional Database Analytical Data Store Based on Relational paradigm Based on Dimensional paradigm Storage of real-time transactional data Storage of historical transactional data Optimized for storage efficiency and data integrity Optimized for data retrieval and summarization Supports day-to-day operations Supports periodic and on-demand analysis

Relational Data Modeling Be able to interpret simple ERDs Draw an ERD based on a scenario description Entities Attributes Entity attributes vs. relationship attributes Primary key and non-key attributes Relationships & Cardinality Maximum cardinality: One-to-one, one-to-many, many-to-many Minimum cardinality: optional or mandatory (i.e., 0 or 1) Best practices for normalization

Cardinality How to understand the notations: Entity – Relationship – Cardinality – Entity makes Customer Order Minimum cardinality: at least – one at most - one at least – zero (optional) at most - many Maximum cardinality: Maxinum cardinality: One customer can have many orders. One order can only belong to one customer. Minimum cardinality: A customer could have no orders. An order has to belong to at least one customer.

Cardinality: Example 1 Each department has many faculty members Maximum: One Each department has many faculty members But each faculty is affiliated with one and only one department Minimum: One Minimum: One (not explicitly stated) Maximum: Many

Cardinality: Example 2 Each student needs to declare at least one and at most two majors (that is, first major and second major) at the beginning of the first year. Maximum: Many Minimum: One Minimum: One (not explicitly stated) Maximum: Many (not explicitly stated)

Relational Data Modeling Draw the corresponding schema of an ERD Given data from two tables, be able to draw the results of a join of those tables with the data correctly “matched up”

Original 1:m relationship Customer CustomerID FirstName LastName City State Zip Order OrderNumber CustomerID OrderDate

Original m:m relationship Order OrderNumber OrderDate OrderProduct OrderProductID OrderNumber ProductID Quantity Product ProductID ProductName Price

Basic SQL SELECTing from a single table will be on this exam JOINS, subselects, etc. will be on the second exam Creating, updating, and deleting tables and rows will also be on the second exam

Basic SQL Given a schema of a database, be able to create a SQL statement to answer a question Understand how to use SELECT FROM DISTINCT WHERE (and how to specify conditions) AND/OR COUNT, AVG, MIN, MAX, SUM GROUP BY ORDER BY (ASC/DESC)

SELECT from 1 Table Recall the Customer table… SELECT * FROM orderdb.Customer; CustomerID FirstName LastName City State Zip 1001 Greg House Princeton NJ 09120 1002 Lisa Cuddy Plainsboro 09123 1003 James Wilson Pittsgrove 09121 1004 Eric Foreman Warminster PA 19111 SELECT FirstName, LastName FROM orderdb.Customer WHERE State=‘NJ’; FirstName LastName Greg House Lisa Cuddy James Wilson

Order By, Group By GROUP BY: ORDER BY: Return the results for each group in the specified field Often used together with the functions COUNT, MIN, MAX, AVG, SUM One result is returned for each group ORDER BY: Sort records based on the specified field or function Default: ASC Specify DESC to make it descending.

Group By (Example) OrderProductID OrderNumber ProductID Quantity 1 101 2251 2 2282 3 2505 4 102 5 6 103 7 104 8 Ask: What is the total quantity sold per order (by order number)? Order-Product SELECT OrderNumber, SUM(Quantity) FROM orderdb.OrderProduct GROUP BY OrderNumber; OrderNumber SUM(Quantity) 101 6 102 7 103 3 104 8

Group By and Order By (Example) OrderProductID OrderNumber ProductID Quantity 1 101 2251 2 2282 3 2505 4 102 5 6 103 7 104 8 Ask: What is the total quantity sold per order (by order number)? Sort the results descendingly based on total quantity sold Order-Product SELECT OrderNumber, SUM(Quantity) FROM orderdb.OrderProduct GROUP BY OrderNumber OrderNumber SUM(Quantity) 104 8 102 7 101 6 103 3 ORDER BY SUM(Quantity) DESC;

DISTINCT and GROUP BY SELECT DISTINCT State FROM orderdb.Customer; NJ PA SELECT State FROM orderdb.Customer GROUP BY State; State NJ PA TIP: GROUP BY can be used without aggregation functions. In this case, the result returned will be similar to DISTINCT

Combining WHERE, GROUP BY, and ORDER BY Recall the Customer table: CustomerID FirstName LastName City State Zip 1001 Greg House Princeton NJ 09120 1002 Lisa Cuddy Plainsboro 09123 1003 James Wilson Pittsgrove 09121 1004 Eric Foreman Warminster PA 19111 Ask: How many customers are there in each city in New Jersey? Order the results alphabetically in descending order by city

One more note: Combining WHERE, GROUP BY, and ORDER BY X SELECT City, COUNT(*) FROM orderdb.Customer WHERE State='NJ' GROUP BY City ORDER BY City DESC; SELECT City, COUNT(*) FROM orderdb.Customer GROUP BY City ORDER BY City DESC WHERE State='NJ'; This is the correct SQL statement This won’t work City COUNT(*) Princeton 1 Plainsboro Pittsgrove When combining WHERE, GROUP BY, and ORDER BY, write the WHERE condition first, then GROUP BY, then ORDER BY.

Good Luck!