QUERYING A DATABASE By: Dr.Ennis-Cole. OBJECTIVES: Learn how to use the Query window in Design view Create, run and Save queries Define a relationship.

Slides:



Advertisements
Similar presentations
Microsoft Access.
Advertisements

Lesson 30: Maintaining a Database. Learning Objectives After studying this lesson, you will be able to:  Change the layout of a table by adjusting column.
Pasewark & Pasewark Microsoft Office XP: Introductory Course 1 INTRODUCTORY MICROSOFT ACCESS Lesson 4 – Finding and Ordering Data.
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Access Lesson 2 Creating a Database
Access Tutorial 3 Maintaining and Querying a Database
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 3 1 Microsoft Office Access 2003 Tutorial 3 – Querying a Database.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
COMPREHENSIVE Access Tutorial 2 Building a Database and Defining Table Relationships.
Querying a Database Microsoft Office Access 2003.
FIRST COURSE Access Tutorial 2 Building a Database and Defining Table Relationships.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 3 Maintaining a Database Using the Design and Update Features of Access.
Access Tutorial 3 Maintaining and Querying a Database
Define Table Relationships—1 of 3 One of the most powerful features of a relational database management system, such as Access, is its ability to define.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory Pasewark & Pasewark.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory.
Chapter 3 Maintaining a Database
Maintaining and Querying a Database Microsoft Access 2010.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
1 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Microsoft Access – Tutorial 3
You can use a query to view a subset of your data or to answer questions about your data. For example, if you want to view a list of student names and.
Access Tutorial 2 Building a Database and Defining Table Relationships
G-Databases Competency 7.00 Objective 7.01 Demonstrate basic database concepts and functions.
® Microsoft Office 2013 Access Building a Database and Defining Table Relationships.
Created by: Tanya Morgan.  Access is the database software of the Microsoft Office suite.  A database is a collection of objects that work together.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
® Microsoft Office 2010 Access Tutorial 2 Building a Database and Defining Table Relationships.
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
XP 1 Microsoft Access 2003 Introduction To Microsoft Access 2003.
Concepts of Database Management Seventh Edition
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
® Microsoft Access 2010 Tutorial 2 Building a Database and Defining Table Relationships.
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
® Microsoft Office 2010 Building a Database and Defining Table Relationships.
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.
Filtering Data A filter is a set of restrictions you place on the records of an open datasheet or form to temporarily isolate a subset of the records.
® Microsoft Access 2010 Tutorial 3 Maintaining and Querying a Database.
Databases,Tables and Forms Access Text by Grauer Chapters 1 & 2.
Access  Getting Started  Creating Tables  Designing Tables Worksheet #8.
Figure 2.1 The Open dialog box in the Startup window. Cancel button Open dialog box folders on drive C.
COMPREHENSIVE Access Tutorial 3 Maintaining and Querying a Database.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
® Microsoft Office 2013 Access Maintaining and Querying a Database.
Pasewark & Pasewark 1 Access Lesson 3 Creating Queries Microsoft Office 2007: Introductory.
Introduction to a Database Defining a database Database window in Access The six items in window: Tables, Queries Forms, Reports, Macros, Modules.
You can sort Access data so you can view records in the order you want to view them, and you can filter data so you only see the records you want to see.
Sorting Data Sorting is the process of rearranging records in a specified order or sequence. When you sort data in a query or table datasheet or in a form.
Pasewark & Pasewark Microsoft Office 2003: Introductory 1 INTRODUCTORY MICROSOFT ACCESS Lesson 4 – Finding and Ordering Data.
XP New Perspectives on Microsoft Access 2002 Tutorial 31 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Work with Tables and Database Records Lesson 3. NAVIGATING AMONG RECORDS Access users who prefer using the keyboard to navigate records can press keys.
Microsoft Access Database Creation and Management.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 2 ® Building Queries.
Course Contents Overview: Database basics Lesson 1: Benefits of using a database Lesson 2: Table that data Lesson 3: Analyzing, viewing, and reporting.
Access Maintaining and Querying a Database
Access Tutorial 3 Maintaining and Querying a Database
Microsoft Access – Tutorial 3
Access Maintaining and Querying a Database
Find and Replace Used to quickly find and/or replace data quickly
Microsoft Office Access 2003
Tutorial 3 – Querying a Database
Microsoft Office Access 2003
Assignment 3 Querying and Maintaining a Database
Presentation transcript:

QUERYING A DATABASE By: Dr.Ennis-Cole

OBJECTIVES: Learn how to use the Query window in Design view Create, run and Save queries Define a relationship between two tables Sort data in a query Filter data in a query Specify an exact match condition in a query

OBJECTIVES: Change a datasheet’s appearance Use a comparison operator to match a range of values Use the AND and OR logical operators Perform the calculations in a query using calculated fields, aggregate functions, and record group calculations

QUERIES: An INTRODUCTION A query is a question you ask about stored data Access provides the following capabilities: –Display selected fields and records from a table –Sort records –Perform calculations –Generate data for forms, reports and other queries –Update data in the tables of a database –Find and display data from two or more tables

QUERY WINDOW You use the Query window to create a Query in Design view By using QBE, you give Access an example of the information you are requesting Access then retrieves the information that precisely matches your example Refer to Figures 3-1 and 3-2

CREATING AND RUNNING A QUERY Drag CustomerNum from the Customer field list Double click CustomerName Repeat the steps for the City, OwnerName and First contact fields Click the Run button Save, type a name and close the window

DEFINING TABLE RELATIONSHIPS Define relationships between tables Use a common field to relate two tables This process is called a JOIN When you join tables that have a common field, you can extract data from them as if they were a single large table

ONE-TO-MANY RELATIONSHIPS: Exists when one record in the first table matches zero, one or many records in the second table, or when one record in the second table matches exactly one record in the first table Access refers to the two tables that form a relationship as the primary table and the related table

ONE-to-MANY RELATIONSHIPS: Primary table: “One” table in a 1:M relation Related table:“Many” table in a1:M relation Because a related table is stored in two tables, inconsistencies between the tables can occur There are 3 major anomalies: –Addition –Deletion & –Update anomalies

REFERENTIAL INTEGRITY Is a set of rules that Access enforces to maintain consistency between related tables Rules of RI: –When you add a record to a related table, a matching record must already exist in the primary table –If you attempt to change the value of the primary key in the primary table, Access prevents this change –When you delete a record in the primary table, Access prevents the deletion if matching records exist in a related table

DEFINING A RELATIONSHIP When two tables have a common field, you can define a relationship between them in the relationships window In this window, you can view or change existing relationships, define and rearrange the table layout Refer to Figures 3-6 & 3-7

SORTING DATA IN A QUERY Is the process of rearranging records in a specified order Often you need to sort before displaying it When you sort, you do not change the sequence of the records in the underlying tables Only the records in the query are rearranged

SORTING DATA IN A QUERY To sort, you must select the Sort key Sort keys can be text, number, date/time, Currency, AutoNumber, Yes/No They are not memo, OLE object or hyperlink objects You sort keys in either ascending or descending order Click the toolbar sort buttons to sort quickly

SORTING MULTIPLE FIELDS IN DESIGN VIEW Sort keys can be unique or non-unique When the sort key is non-unique, records with the same sort key value are grouped together But, they are not in a specific order within the group To arrange these, you can specify a Secondary Key

SORTING A QUERY DATASHEET The first sort key field is called the primary sort key A table has at most one primary key, which must be unique Any field in a table can serve as a primary sort key Access lets you select up to 10 different sort keys

SORTING & FILTERING DATA In the Query datasheet, select the field or adjacent fields on which you want to sort Click the Sort Ascending button or the Sort Descending button on the Query Datasheet toolbar A Filter is a set of restrictions you place on the records in an open datasheet or form to temporarily isolate a subset of the records In the datasheet, select all for filter Click the Filter By Selection button the toolbar

DEFINING RECORD SELECTION CRITERIA FOR QUERIES Just as you can display selected fields, you can display selected records You must specify a condition as part of the query A condition is a criteria that determines which records are selected It consists of an operator and a value It could be a comparison operator or an exact match Refer to Figures 3-17 through 3-20

CHANGING A DATASHEET’S APPEARANCE You can change characteristics of a datasheet Click the Maximize button Click the record selector to select the entire sheet Click Format, Font Scroll, Click 8, Click OK button Press and hold the shift key, then click the mouse button, all columns are selected Double-click the mouse button, all columns are resized to their best fit Click Save and Close

DEFINING MULTIPLE SELECTION CRITERIA FOR QUERIES Multiple selection requires you to use logical operators They combine two or more conditions When you want to select a record, only if two or more conditions are met, use the AND Operator When you place conditions in different criteria rows, you use the OR logical operator See Figure 3-25

The End !