Computer Science & Engineering 2111 Querying a Database 1CSE 2111 Lecture- Querying a Database.

Slides:



Advertisements
Similar presentations
Relational Database Systems Higher Information Systems Advanced Implementation in MySQL/PHP.
Advertisements

Organisation Of Data (1) Database Theory
4d. Structured Query Language – JOIN Operation Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets.
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Computer Science & Engineering 2111 CONDITIONAL STATISTICAL FUNCTIONS 1 CSE 2111 Lecture Conditional Statistical Functions.
© 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 10 – Designing.
Computer Science & Engineering 2111 Introduction to Database Systems 1CSE 2111-Introduction to Database Systems.
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
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.
3 / 12 CHAPTER Databases MIS105 Irfan Ahmed Ilyas.
Interpreting SQL Code. SQL (The language used to query a database) S is used to specify the you want to include. F is used to specify the the selected.
Computer Science & Engineering 2111 CSE 2111 Lecture Querying a Database 1CSE 2111 Lecture- Querying a Database.
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
Computer Science & Engineering 2111 Introduction to Database Management Systems Relationships and Database Creation 1 CSE 2111 Introduction to Database.
Computer Science & Engineering 2111 CSE 2111 Lecture Basic Criteria in Queries 1CSE 2111 Lecture-Basic Criteria in Queries.
Microsoft Access Database software. What is a database? … a database is an organized collection of data. A collection of data of similar information compiled.
Resources – MS Access Free Online Training Resources  Using an Access database to store and information (2 min)
DB Implementation: MS Access Queries. MS Access Queries Database Queries Core DBA skill From SQL to Query by Example (QBE) What does it do? Find target.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
CS&E 1111 AcQueries Writing Simple Queries in Access Displaying on specific data fields Filtering data using criteria Objectives: Learn how to use the.
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.
CS&E 1111 AcQueries Querying in Access Sorting data Aggregating Data Performing Calculations Objectives: Learn how to use the Access Query Design Tool.
CS&E 1111 AcInnerJoins Inner Joins Objectives: Creating Queries with data from Multiple Tables Joining two tables using an Inner Join Referential Data.
Microsoft Access Lecture -13- By lec. (Eng.) Hind Basil University of Technology Department of Materials Engineering 1.
Access Primer UoN workshop Naivasha, 30 July – 4 August 2006.
Simple Database.
Introduction to Microsoft Access 2003 Mr. A. Craig Dixon CIS 100: Introduction to Computers Spring 2006.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
Analyzing Data For Effective Decision Making Chapter 3.
Computer Science & Engineering 2111 Lecture 11 Querying a Database 1.
Introduction to Computers Lesson 10B. home Database A collection of related data or facts.
Introduction to Computers Lesson 10B. home Database A collection of related data or facts.
1 Database Concepts 2 Definition of a Database An organized Collection Of related records.
Computer Science & Engineering 2111 Lecture 10 Introduction to Database Management Systems 1.
Querying a Database Access Project 2. 2 What is a Query?  In general, a query is a form of questioning, in a line of inquiry. A query may also refer.
® Microsoft Access 2010 Tutorial 9 Using Action Queries and Advanced Table Relationships.
Databases: An Overview Chapter 7, Exploring the Digital Domain.
SESSION 3.1 This section covers using the query window in design view to create a query and sorting & filtering data while in a datasheet view. Microsoft.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Ch Determine the output displayed from procedures Lab sheet 10.4.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making Chapter.
Computer Science & Engineering 2111 CSE 2111 Lecture Multiple and Compound Criteria in Queries 1 CSE 2111 Lecture-Multiple and Compound Criteria in Queries.
Database Management Systems.  Database management system (DBMS)  Store large collections of data  Organize the data  Becomes a data storage system.
Microsoft Access 2013 ®® Tutorial 9 Using Action Queries and Advanced Table Relationships.
Computer Science & Engineering 2111 CSE 2111 Lecture NZ Function 1CSE 2111 NZ Function.
Computer Science & Engineering 2111 Outer Joins 1CSE 2111 Lecture- Inner Vs. Outer Jioins.
The Advantage Series © 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating Select Queries Chapter 6 Microsoft Office Access 2003.
DAY 16: MICROSOFT ACCESS – CHAPTER 2 Madhuri Siddula October 8, 2015.
Database Management System. DBMS A software package that allows users to create, retrieve and modify databases. A database is a collection of related.
IS201 Agenda: 09/19  Modify contents of the database.  Discuss queries: Turning data stored in a database into information for decision making.  Create.
Access Chapter 1: Intro to Access Objectives Navigate among objects in Access database Difference between working in storage and memory Good database file.
Computer Science & Engineering 2111 Lecture 13 Outer Joins 1.
Chapter 13.3: Databases Invitation to Computer Science, Java Version, Second Edition.
1 Query Name:Query 1Tables Required:People/Violations Foreign Keys:LIS#Join Type:Inner Field LastNameFirstNameLIS#State Table People Violations Total Sort.
Computer Science & Engineering 2111 Sorting in Queries 1CSE 2111 Lecture-Advanced Queries.
® Microsoft Access 2010 Tutorial 9 Using Action Queries and Advanced Table Relationships.
VOCAB REVIEW. A field that can be computed from other fields Calculated field Click for the answer Next Question.
Computer Science & Engineering 2111 Inner Joins and Advanced Queries 1CSE 2111 Lecture-Advanced Queries.
DAY 20: ACCESS CHAPTERS 5, 6, 7 Larry Reaves October 28,
Writing Simple Queries in Access
Introduction to Database Systems
Tables & Relationships
Basic Criteria in Queries
Basic Criteria in Queries
Introduction to Database Systems
Database Queries.
Lesson 3 Chapter 10.
Presentation transcript:

Computer Science & Engineering 2111 Querying a Database 1CSE 2111 Lecture- Querying a Database

What is a Database Query? 2 A request for information from a database To extract information from the Database you must use a Query which is a “question” or “request” – Criterion An expression that tells the DBMS which records to retrieve Make up of conditions – Can be one conditions or many When you run the query a dynaset, or subset of the database is displayed. You can make changes to this dynaset and the changes will be reflected in your database, because the dynaset is just a view of your database. CSE 2111 Lecture- Querying a Database

3 Query By Example (QBE) Grid CSE 2111 Lecture- Querying a Database Dynaset created when Query is run

SQL is the language you use to talk to the database MS Access 2010 supplies a graphical user interface (GUI) called the Query By Example Grid or (QBE) grid MS Access 2010 creates the SQL for you. 4 Structured Query Language (SQL) CSE 2111 Lecture- Querying a Database

5 SQL Created from QBE Grid CSE 2111 Lecture- Querying a Database

Write a query to list the First Name and Last Name and state for all clients who live in Ohio. Field FirstNameLastNameState Table Client Sort Show xxx Criteria “oh” OR 6 Query Name: Ohio Residents Tables Required: Client Foreign Keys: None Join Type: None When typing in non-numeric criteria, always surround the criteria with quotes. CSE 2111 Lecture-Basic Criteria in Queries

The data table The resulting dynaset CSE 2111 Lecture-Basic Criteria in Queries7

Write a query to list the ClientID for all payments of $100. Field ClientIDAmount Table Payments Sort Show x Criteria 100 OR 8 Query Name: PaymentOf100 Tables Required: Payments Foreign Keys: None Join Type: None When typing in numeric criteria, DO NOT surround the criteria with quotes. CSE 2111 Lecture-Basic Criteria in Queries

The data table The resulting dynaset CSE 2111 Lecture-Basic Criteria in Queries9

Write a query to list the Client ID, payment, and payment date for all payments made on March 8, Field ClientIDAmountPaymentDate Table Payments Sort Show xxx Criteria #3/8/2008# OR 10 Query Name: March8 Tables Required: Payments Foreign Keys: None Join Type: None When typing in date criteria, always surround the criteria with #. CSE 2111 Lecture-Basic Criteria in Queries

The data table The resulting dynaset CSE 2111 Lecture-Basic Criteria in Queries11

Write a query to list the ClientID and payment for all payments of $100 or more. Field ClientIDAmount Table Payments Sort Show xx Criteria >=100 OR 12 Query Name: Payment>=100 Tables Required: Payments Foreign Keys: None Join Type: None When typing in numeric criteria, DO NOT surround the criteria with quotes. CSE 2111 Lecture-Basic Criteria in Queries

The data table The resulting dynaset CSE 2111 Lecture-Basic Criteria in Queries13

Wild cards in Criteria An asterisk * replaces any number of characters Used with the keyword, Like – Like “C*” – in Product Name field will select c, Cookie, cake. – Like “*cookie*” - in Product Name field will select all records that include the word cookie in the Product Name field A ? replaces a single character – Like “B?” – in the Category field will select all records that c onsists of two characters and start with the letter “B” CSE 2111 Lecture-Wild Cards and Key Words in Queries 14

Write a query to list the First Name and Last Name for all clients who live within the 614 area code. Field FirstNameLastNameHomePhone Table Client Sort Show xx Criteria Like “614*” OR 15 Query Name: Phone#614 Tables Required: Client Foreign Keys: None Join Type: None CSE 2111 Lecture-Wild Cards and Key Words in Queries

The resulting dynaset CSE 2111 Lecture-Wild Cards and Key Words in Queries 16 The data table

Write a query to list the First Name and Last Name of all clients who DO NOT live within the 614 area code. Field FirstNameLastNameHomePhone Table Client Sort Show xx Criteria Not Like “614*” OR 17 Query Name: NotPhone#614 Tables Required: Client Foreign Keys: None Join Type: None CSE 2111 Lecture-Wild Cards and Key Words in Queries

The resulting dynaset CSE 2111 Lecture-Wild Cards and Key Words in Queries 18 The data table

Write a query to list the Client ID of all clients whose Client ID consists of 5 characters beginning with J75 and ending with 0. Field ClientID Table Clients Sort Show X Criteria Like “j75?0” OR 19 Query Name: J75?0 Tables Required: Client Foreign Keys: None Join Type: None CSE 2111 Lecture-Wild Cards and Key Words in Queries

The resulting dynaset CSE 2111 Lecture-Wild Cards and Key Words in Queries 20 The data table

Field ClientIDLastNameAmount Table Client Payments Sort Show xxx Criteria OR 21 Query Name:InnerJoinExampleTables Required:Client/Payments Foreign Keys:ClientIDJoin Type:Inner CSE 2111 Lecture-Inner Joins in Queries

The resulting dynaset Dynaset only includes records that have matching keys on both tables. This is called an inner join which is the default join type in Access CSE 2111 Lecture-Inner Joins in Queries22 The data tables

Multiple conditions in a Query Boolean Operators - AND, OR For conditions in multiple fields the placement of your arguments determines the Boolean relationship between those arguments If a criteria is on the same line it is automatically considered an AND If a criteria is on a separate line it is automatically considered an OR CSE 2111 Lecture-Multiple and Compound Criteria in Queries 23

Write a query to list the First Name, Last Name, and amount for all clients who paid $250 or more or made payments of less than $ Query Name: Example1Tables Required: Client/Payments Foreign Keys: ClientIDJoin Type:Inner Field FirstNameLastNameAmount Table Client Payments Sort Show xxx Criteria >= 250 OR < 75 OR Query Name: Example2Tables Required: Client/Payments Foreign Keys: ClientIDJoin Type:Inner Field FirstNameLastNameAmount Table Client Payments Sort Show xxx Criteria >= 250 or < 75 OR CSE 2111 Lecture-Multiple and Compound Criteria in Queries

The resulting dynaset 25 CSE 2111 Lecture-Multiple and Compound Criteria in Queries The data tables

Write a query to list the First Name, Last Name, amount and payment date for all clients who paid more than $100 on or after 3/3/2008. Field FirstNameLastNameAmountPaymentDate Table Client Payments Sort Show xxxx Criteria > 100>= #3/3/2008# OR 26 Query Name:AndExampleTables Required:Client/Payments Foreign Keys:ClientIDJoin Type:Inner CSE 2111 Lecture-Multiple and Compound Criteria in Queries

The resulting dynaset CSE 2111 Lecture-Multiple and Compound Criteria in Queries 27 The data tables

Write a query to list the First Name and Last Name of all clients who made payments between 1/1/2008 and 3/8/2008. Field FirstNameLastNamePaymentDate Table Client Payments Sort Show xxx Criteria Between #1/1/2008# And #3/8/2008# OR 28 Query Name:BetweenExampleTables Required:Client/Payments Foreign Keys:ClientIDJoin Type:Inner CSE 2111 Lecture-Multiple and Compound Criteria in Queries

The resulting dynaset CSE 2111 Lecture-Multiple and Compound Criteria in Queries 29 The data tables

Write a query to list the First Name, Last Name, amount and payment date for all clients who paid more than $100 on or after 3/3/2008 or made a payment of $100. Field FirstNameLastNameAmountPaymentDate Table Client Payments Sort Show xxxx Criteria > 100>= #3/3/2008# OR 100 OR 30 Query Name:CompoundExampleTables Required:Client/Payments Foreign Keys:ClientIDJoin Type:Inner CSE 2111 Lecture-Multiple and Compound Criteria in Queries

The resulting dynaset CSE 2111 Lecture-Multiple and Compound Criteria in Queries 31 The data tables