Tuesday, September 28, 1999 90-728 MIS Lecture Notes1 Midterm Exam: Tuesday, September 28 Covers all course material through today’s lecture: –Homeworks.

Slides:



Advertisements
Similar presentations
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Advertisements

Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Introduction to Structured Query Language (SQL)
Instructor: Craig Duckett CASE, ORDER BY, GROUP BY, HAVING, Subqueries
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
Chapter 14: Advanced Topics: DBMS, SQL, and ASP.NET
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Concepts of Database Management Sixth 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.
Microsoft Access 2010 Chapter 7 Using SQL.
INFORMATION TECHNOLOGY IN BUSINESS AND SOCIETY SESSION 16 – SQL SEAN J. TAYLOR.
DAY 16: ACCESS CHAPTER 2 Tazin Afrin October 10,
Exploring Office Grauer and Barber 1 Information From the Database: Reports and Queries(Wk4)
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
Concepts of Database Management, Fifth Edition
ASP.NET Programming with C# and SQL Server First Edition
SQL 資料庫查詢語言 取材自 EIS, 3 rd edition By Dunn et al..
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
Chapter 3 Single-Table Queries
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access Committed to Shaping the Next Generation.
Microsoft Access 2010 Chapter 7 Using SQL. Change the font or font size for SQL queries Create SQL queries Include fields in SQL queries Include simple.
CSE314 Database Systems More SQL: Complex Queries, Triggers, Views, and Schema Modification Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
Analyzing Data For Effective Decision Making Chapter 3.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 6 – Designing.
Concepts of Database Management Seventh Edition
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Exploring Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 3 - Information From the Database: Reports.
 Agenda 2/20/13 o Review quiz, answer questions o Review database design exercises from 2/13 o Create relationships through “Lookup tables” o Discuss.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Intro to SQL Management Studio. Please Be Sure!! Make sure that your access is read only. If it isn’t, you have the potential to change data within your.
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 3 Query and Report. Agenda Report types Report contents Report creation Report design view Query and dynaset Function and grouping Action query.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
1 Chapter 3: Customize, Analyze, and Summarize Query Data Exploring Microsoft Office Access 2007.
IMS 4212: Data Manipulation 1 Dr. Lawrence West, MIS Dept., University of Central Florida Additional Data Manipulation Statements INSERT.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Database Management Supplement 1. 2 I. The Hierarchy of Data Database File (Entity, Table) Record (info for a specific entity, Row) Field (Attribute,
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
IS201 Agenda: 09/19  Modify contents of the database.  Discuss queries: Turning data stored in a database into information for decision making.  Create.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
Access Queries Agenda 6/16/14 Review Access Project Part 1, answer questions Discuss queries: Turning data stored in a database into information for decision.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
Mining real world data RDBMS and SQL. Index RDBMS introduction SQL (Structured Query language)
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
SQL. Originally developed by IBM Standardized in 80’s by ANSI and ISO Language to access relational database and English-like non-procedural Predominant.
 Review quiz. Answer questions.  Discuss queries: ◦ What is a query? Turning data stored in a database into information for decision making. ◦ You: Completed.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Lecture3b - Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data Guide to Oracle 10g ITBIS373 Database Development.
MIDTERM REVIEW IST 210 Organization of Data IST210 1.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Querying Database ISYS 363.
Contents Preface I Introduction Lesson Objectives I-2
Shelly Cashman: Microsoft Access 2016
Chapter 3 Query and Report.
Presentation transcript:

Tuesday, September 28, MIS Lecture Notes1 Midterm Exam: Tuesday, September 28 Covers all course material through today’s lecture: –Homeworks 1 - 5; Problem 1 of Homework #6 –All lectures –All handouts –Readings from Stair and Reynolds and Rob and Coronel Will be pencil-and-paper –No computers or calculators are necessary Will include: –Relational database design (about 60%) –Short answer/True-False (about 30%/10%) Review sessions will be held: –Wednesday 9/29, 5:30 PM - 7 PM, Room 255 Baker Hall –Saturday 10/2, 1 PM - 4 PM, Room 1003 HbH Homework #6 (Queries) due Tuesday, October 12

Tuesday, September 28, MIS Lecture Notes2 Query Logic and Design Queries are sequences of commands used to extract and combine data. Using the department store example, what are typical questions that could be answered via queries? – While tables store data, and relationships encode business rules that link data in multiple tables, only queries assist in the transformation of data into information

Tuesday, September 28, MIS Lecture Notes3 Design and Use of Queries In Access, queries are designed and executed using three views: –Design view –Datasheet view –SQL view Queries are used: –to perform ad-hoc data analysis –to populate recordsets used in forms –to populate controls such as combo boxes and text boxes –to organize data for reports –as part of macros and code for custom processing tasks

Tuesday, September 28, MIS Lecture Notes4 Structured Query Language Queries are executed using Structured Query Language (SQL). SQL has a number of advantages compared to sequential programs implemented in third-generation languages such as C or Pascal: –SQL is simple: there are only thirty or so commands –SQL is nonprocedural: data storage details are shielded from the user; –SQL is platform-independent: queries can be represented identically on different platforms; –SQL is GUI-compatible: queries can be written in Access and other languages with a GUI alone. You may eventually find that some queries are more easily expressed using SQL than via an interface

Tuesday, September 28, MIS Lecture Notes5 SQL SELECT Many queries are based on the command which extracts a set of records from a table for further analysis: SELECT  Design View SQL View   Datasheet View

Tuesday, September 28, MIS Lecture Notes6 SQL SELECT (cont’d) The general SELECT command uses many clauses : SELECT [INTO ] FROM [WHERE ] [GROUP BY ] The SELECT command can extract a set of columns from one table, or a set of columns from different tables for which pairs of tables have Foreign Key relationships. The INTO clause specifies a table which will store results of this query. The FROM clause lists the table(s) used in the query The WHERE clause lists logical conditions that must be satisfied. The GROUP BY clause lists the attributes by which rows will be aggregated.

Tuesday, September 28, MIS Lecture Notes7 SQL SELECT- Using String Expressions New columns in queries may be assigned values using a variety of string expressions: –[ColName1] & [ColName2] (concatenation): appends one string field to another. Ex: [SName] & “ - “ & [Sex] applied to “Richards” & “ - “ “M” yields “Richards - M” –Left([ColName], N): extracts first N characters of column ColName. Similarly: Right([ColName], N) Ex: Left([SName], 1) applied to “Richards” yields “R” –Mid([ColName], N, M): extracts M characters of column ColName starting at character #N Ex: Mid([CrsNbr],4,1) applied to “ACC610” yields “6” –Len([ColName]): returns the length of column ColName Ex: Len([SID]) applied to “218” yields 3.

Tuesday, September 28, MIS Lecture Notes8 SQL SELECT- Using Arithmetic Expressions New columns in queries may also be assigned values using a variety of arithmetic expressions: –[ColName1] + [ColName2] (addition): add the contents of two columns. Similarly for “-” (subtraction) –[ColName1] * [ColName2] (multiplication): subtracts the contents of one column from another. Similarly for “/” (division) –[ColName]^N (exponentiation): computes the value of a column to the power N (N can be any real number) –Abs([ColName]) (absolute value): computes the absolute value of a column ex.: Abs([Temperature]) applied to “-32” gives “32” –Int([ColName]): returns the integer portion of a real number ex.: Int([InterestRate]) applied to “8.325” gives “8”

Tuesday, September 28, MIS Lecture Notes9 SQL WHERE: Criteria for Selecting Rows Logical expressions can determine rows to appear in query output: –WHERE LogicalExpression([ColName]) Ex: WHERE Left([Sname],1) < “S” chooses all rows where the first initial of the last name is lower than “S” Ex: WHERE Major Is Null selects all rows where the value of the field “Major” is Null (empty) Other operators: BETWEEN, LIKE, IN, EXISTS –WHERE LogicalExpression1([ColName1]) OR LogicalExpression2([ColName2]) (Logical OR) Ex: (Left([SName],1) 2.5) chooses all rows where the first initial of the last name is lower than “P” OR the GPA exceeds 2.5 –WHERE LogicalExpression1([ColName1]) AND LogicalExpression2([ColName2]) (Logical AND) Ex: (Left([SName],1) 2.5) chooses all rows where the first initial of the last name is lower than “P” AND the GPA exceeds 2.5

Tuesday, September 28, MIS Lecture Notes10 SQL GROUP BY: Aggregate Records The GROUP BY clause divides records into groups based on the value of a criterion. New fields may be created using summarized values of fields in each category. Example: –SELECT Major, Avg(GPA) AS AvgOfGPA FROM STUDENT GROUP BY STUDENT.Major Other summary calculations: Sum, Min, Max, Count, StDev, Var, First, Last

Tuesday, September 28, MIS Lecture Notes11 Access Variations on SELECT Queries UPDATE: Calculates a new value for an existing column using arithmetic/string expressions for rows satisfying certain criteria. For example: –UPDATE FACULTY SET FACULTY.FName = "Kennedy-Jenkins" WHERE (([FName]="Kennedy"))

Tuesday, September 28, MIS Lecture Notes12 Access Variations on SELECT Queries (cont’d) APPEND: Adds records from the current query to another table with identical format. For example: – INSERT INTO FACULTY4 SELECT FACULTY3.* FROM FACULTY3;

Tuesday, September 28, MIS Lecture Notes13 Access Variations on SELECT Queries (cont’d) MAKE TABLE: Creates a new table based on results from the current query. For example: –SELECT FACULTY3.FID, FACULTY3.FName INTO FACULTY_NEW FROM FACULTY3 GROUP BY FACULTY3.FID, FACULTY3.FName ORDER BY FACULTY3.FID;

Tuesday, September 28, MIS Lecture Notes14 Access Variations on SELECT Queries (cont’d) DELETE: deletes all records satisfying certain criteria. Example: – DELETE STUDENT2.*, STUDENT2.GPA FROM STUDENT2 WHERE (((STUDENT2.GPA)<=2.5));

Tuesday, September 28, MIS Lecture Notes15 Access Variations on SELECT Queries (cont’d) CROSSTAB: creates a two-dimensional table in which a value field is summarized according to row and column field(s). Example: –TRANSFORM Avg(STUDENT.GPA) AS AvgOfGPA SELECT STUDENT.Major FROM STUDENT GROUP BY STUDENT.Major PIVOT STUDENT.Sex;

Tuesday, September 28, MIS Lecture Notes16 Parameter Queries Parameter Queries: Select records that match a user-defined criterion based on a particular field. Example: –SELECT COURSE.* FROM COURSE WHERE (((COURSE.CrsNbr)=[Select a course number:]));

Tuesday, September 28, MIS Lecture Notes17 Other Query Applications Views: Select a row driver, and add one or more tables, each pair of which is linked by a Foreign key relationship. Select columns of interest for output. Find Duplicate Records: Find the records in a table that have identical values for all columns Find Unmatched Records: Find the records in one table without records in another table according to a common field Archive: Select records according to given criteria (SELECT query); create a new table based on query results (MAKE TABLE query), delete selected records from original table (DELETE query) Select Top X Records: Select the top X (X%) records according to given criteria

Tuesday, September 28, MIS Lecture Notes18 Data Analysis Applications of Queries Suppose you have a number of fields that could serve as indexes or foreign keys, but with inconsistent information: –“Degree attained” = “Bachelor’s”, “B.A.”, “A.B”, “MPM”, “M.S.” How could you derive a consistent set of values? Now suppose you have a dataset describing customers with a number of candidate keys: –Last name, Phone number, Street address How could you determine a primary key (if one exists)? Finally, you want to determine the distribution of family income by marital status and gender: –“Marital Status” = “Married”, “Separated”, “Divorced”, … How would you calculate this distribution?