Querying Database. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy Calculated.

Slides:



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

COMP 3715 Spring 05. Working with data in a DBMS Any database system must allow user to  Define data Relations Attributes Constraints  Manipulate data.
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Exploring Microsoft Excel 2002 Chapter 7 Chapter 7 List and Data Management: Converting Data to Information By Robert T. Grauer Maryann Barber Exploring.
Microsoft Excel Working with Excel Lists, Subtotals and Pivot Tables.
Database Features. Lists n An Excel worksheet can be used like a table in a relational database. n In Excel, such a table is called a list. n Each row.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
Querying Database ISYS 363. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy.
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Structured Query Language Review ISYS 650. Language Overview Three major components: –Data definition language, DDL Create, Drop and Alter Tables or Views.
Querying a Database Using the Select Query Window
1 SQL-Structured Query Language SQL is the most common language used for creating and querying relational databases. Many users can access a database applications.
Basic SQL Select Commands. Basic Relational Query Operations Selection Projection Natural Join Sorting Aggregation: Max, Min, Sum, Count, Avg –Total –Sub.
Querying Database ISYS 363. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy.
Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages.
Structured Query Language Part I Chapter Three CIS 218.
Relational Algebra. Set operations: Union, intersection, difference, Cartesian product Relational operations: Selection, projection, join, division.
Chapter 2 Querying a Database
Concepts of Database Management Sixth Edition
Introduction to Structured Query Language SQL. SQL Select Command SELECT * FROM tableName WHERE criteria;
Relational Operators, SQL, and Access Query ISYS 562.
Microsoft Access 2010 Chapter 7 Using SQL.
Computer Science 101 Web Access to Databases SQL – Extended Form.
Exploring Office Grauer and Barber 1 Information From the Database: Reports and Queries(Wk4)
Concepts of Database Management, Fifth Edition
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
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.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
Relational Query Operators (ii). Other Joins Theta join: Apply any specified condition on the product of two relations. Example: BoyStudent: BID, Bname,
1 Chapter 7 Query-By-Example by Monica Chan CS157B Professor Lee.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
Microsoft Access 2010 Building and Using Queries.
Analyzing Data For Effective Decision Making Chapter 3.
Access Class Outline Data Organization Tables Import and Export of Data Queries Select Calculate Values Aggregation (Count, Sum) Create Append Delete Crosstab.
Concepts of Database Management Seventh Edition
Advanced SQL for Decision Support ISYS 650. Set Operators Union Intersect Difference Cartesian product.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
Exploring Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 3 - Information From the Database: Reports.
MICROSOFT ACCESS With your host: Daniel McAllister.
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.
Introduction to Access ISYS 363. Creating a New Database MS Office button/New –Blank database –New database name and location.
Reports and Queries Chapter 3 – Access text Reports – Page Queries – Page
Relational Query Operators (Algebra). Relational Query Operators Set operations: Union, intersection, difference, Cartesian product Relational operations:
Querying Database ISYS 363.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
Introduction to Query Language and SQL. Basic Query Language Operators Selection Projection Join Aggregates –Sum, Count, Max, Min, Avg SubTotal Calculated.
Access Chapter 1: Intro to Access Objectives Navigate among objects in Access database Difference between working in storage and memory Good database file.
(SQL - Structured Query Language)
Introduction to Access BUS 782. Creating a New Database MS Office button/New –Blank database –New database name and location.
Introduction to Access ISYS 363. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages.
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
WEEK# 12 Haifa Abulaiha November 02,
Introduction to Access ISYS 363. Access Objects Tables –Open a table: Double click the table name –Home/View: Datasheet view Design view Queries Forms.
Set Operators. Union Intersect Difference Cartesian product.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
VOCAB REVIEW. A field that can be computed from other fields Calculated field Click for the answer Next Question.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
MICROSOFT ACCESS With your host: Daniel McAllister.
MS Access: Creating Advanced Queries
Querying Database ISYS 363.
Access: SQL Participation Project
Structured Query Language
Access Tutorial 5 Creating Advanced Queries and Enhancing Table Design
Query Functions.
Lesson 3 Chapter 10.
Chapter 3 Query and Report.
Presentation transcript:

Querying Database

Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy Calculated fields

Selection Selection operation retrieves records that satisfy user’s criteria.

Projection Projection operation defines a vertical subset of a table and retrieves only the specified fields.

Join The two tables must have common attributes: –Key and foreign key. Combines two tables to form a new table where records of the two tables are combined if the common attributes have the same value.

Example Faculty File: FIDFname F1Chao F2Smith Student File: SIDSname FID S1PeterF1 S2PaulF2 S3SmithF1 Faculty Join Student =

Aggregate Functions Max, Min, Sum, Count, Avg Ex. Student: SID,Sname, GPA, Sex, Major –How many students in this University? –What is the overall average GPA?

Aggregates by Group –How many students in each major? –Compare male students and female students average GPA.

Examples Customer: CID, Cname, City, Rating Orders: OID, Odate, SalesPerson, CID Queries: –Find customers live in San Francisco. –Produce a customer report that shows CID, Cname, and Rating. –Number of customers in each city City, NumbeOfCustomers –Produce a report that shows the total number of orders for each customer: CID, Cname, TotalNumberOfOrders

Access Query Demo Select fields Rename a field: –NewName:OldName Define a calculated field: –Tax:salary*.15 –Age:Year(Now()) – Year(DOB) –IIF function

Criteria >, >=, Range: BETWEEN 1/1/03 AND 12/31/03 Wildcard: –? – match any one character “K?NG” –* - Match any number of characters “C*”

Complex condition Rating = “A” OR Rating = “B” Cname = “Chao” OR Cname = “Smith” Rating = “A” OR Rating = “B” AND City=“SF” (Rating = “A” OR Rating = “B”) AND City=“SF”

Sorting One field sorting Two fields sorting

Total and Subtotal View/Totals –GroupBY –Other functions Examples: –Total number of customers –Number of customers in each city City, NumbeOfCustomers

Join Customer Join Orders Example: –Produce a report that shows the total number of orders for each customer: CID, Cname, TotalNumberOfOrders

Other Queries Update query Delete query Parameter query CrossTab query

Other Tools File/Get External Data File/Export

Comparsion between Excel and Access

Excel’s Database Tools Data –Sort –Filter –Subtotals –Pivot table/Pivot chart OLAP: On Line Analytical Process –Import external data Import data New web query New database query

Word’s Database Tools Tools/Letter and Mailing –Mail merge