DESIGNING, BUILDING, AND USING DATABASES (BEGINNING MICROSOFT ACCESS, X405.4)

Similar documents
Microsoft Access Illustrated. Unit B: Building and Using Queries

Microsoft Office Illustrated Introductory, Building and Using Queries

Microsoft Access 2010

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

Microsoft Access 2013

Microsoft Access 2013

Access - Introduction to Queries

Enforce Referential. dialog box, click to mark the. Enforce Referential. Integrity, Cascade Update Related Fields, and. Cascade Delete Related

Microsoft Office 2010: Introductory Q&As Access Chapter 2

Complete Quick Reference Summary

Getting started with Ms Access Getting Started. Primary Key Composite Key Foreign Key

Name: Class: Date: Access Module 2

Access Intermediate

Microsoft Access 2007 Module 2

Access Intermediate

PowerPoint Presentation to Accompany GO! All In One. Chapter 13

Access Module 2: Building and Using Queries

Table of Contents COURSE OVERVIEW... 5

Level 6 Relational Database Unit 3 Relational Database Development Environment National Council for Vocational Awards C30147 RELATIONAL DATABASE

Shelly Cashman Series Microsoft Office 365 and Access 2016 Introductory 1st Edition Pratt TEST BANK

Microsoft Access 2010

Englische Access 2016-Trainingsskripte für IT Seminare und EDV Schulungen als Word-Dokument zum Ausdrucken und fürs Intranet

Creating a Crosstab Query in Design View

Microsoft Access 2016

Microsoft Access 2016

When you pass Exam : Access 2010, you complete the requirements for the Microsoft Office Specialist (MOS) - Access 2010 certification.

Using Microsoft Access

Objective 1: Familiarize yourself with basic database terms and definitions. Objective 2: Familiarize yourself with the Access environment.

MODULE 5 DATABASES. Content

SOFTWARE SKILLS BUILDERS

Microsoft Access XP Queries. Student Manual

Access: Printing Data with Reports

Data Should Not be a Four Letter Word Microsoft Excel QUICK TOUR

Word Module 5: Creating and Formatting Tables

Introducing Gupta Report Builder

COMM 391 Winter 2014 Term 1

STIDistrict Query (Basic)

Microsoft Access 2010

Access Review. 4. Save the table by clicking the Save icon in the Quick Access Toolbar or by pulling

Microsoft Office Access Learn how to use the Query window in Design view. Tutorial 3b Querying a Database

Princeton University Exercise Workbook Training Developed by Elisabetta Zodeiko, Princeton University

Microsoft Office Excel 2003

Database Design Practice Test JPSFBLA

Final Practice. True/False Indicate whether the statement is true or false. Name: Class: Date: 1. An Access database may be as large as 200 gigabytes.

Nutzen Sie die Dettmer-Seminarunterlagen für Access bei einmaligem Kauf über Jahre hinaus für Ihre eigenen Schulungen

Patricia Andrada Quick Guide Excel 2010 Data Management-July 2011 Page 1

Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex

Creating Reports in Access 2007 Table of Contents GUIDE TO DESIGNING REPORTS... 3 DECIDE HOW TO LAY OUT YOUR REPORT... 3 MAKE A SKETCH OF YOUR

Tutorial 3 Maintaining and Querying a Database. Finding Data in a Table. Updating a Database

Access 2007: Advanced Instructor s Edition

SUM - This says to add together cells F28 through F35. Notice that it will show your result is

Chapter 4. Microsoft Excel

Microsoft Access 2013

Skills Exam Objective Objective Number. Creating crosstab queries Create a crosstab query

WAAT-PivotTables Accounting Seminar

Microsoft Excel Level 2

Microsoft Access 2010

MS-Access : Objective Questions (MCQs) Set 1

SECTION 4 USING QUERIES. What will I learn in this section?

SPREADSHEET (Excel 2007)

Microsoft Access 5: Reports & Other Useful Functions

MS Excel Advanced Level

Microsoft Office Specialist Access 2016

Management Reports Centre. User Guide. Emmanuel Amekuedi

ITEC 101 LAB 9 USING A DATABASE: Tables and Queries

Using Microsoft Access

Separate Text Across Cells The Convert Text to Columns Wizard can help you to divide the text into columns separated with specific symbols.

Preview. MS Access Tutorial. Data Files Available on

Using Reports. Access 2013 Unit D. Property of Cengage Learning. Unit Objectives. Files You Will Need

Introduction to PeopleSoft Query. The University of British Columbia

Microsoft Access Basics

Microsoft Access II 1.) Opening a Saved Database Music Click the Options Enable this Content Click OK. *

THE EXCEL ENVIRONMENT... 1 EDITING...

Introduction to Microsoft Excel 2010

Excel 2016 Basics for Windows

M I C R O S O F T A C C E S S : P A R T 2 G E T T I N G I N F O R M A T I O N O U T O F Y O U R D A T A

Log into your portal and then select the Banner 9 badge. Application Navigator: How to access Banner forms (now called pages.)

Quick Guide for Excel 2015 Data Management November 2015 Training:

Document Editor Basics

6. Essential Spreadsheet Operations

Exploring Microsoft Office Access Chapter 2: Relational Databases and Multi-Table Queries

User Guide. DataInsight-Web

INTRODUCTION... 1 UNDERSTANDING CELLS... 2 CELL CONTENT... 4

Searching and Favorites in Datatel Web UI 4.3

Create and Modify Queries 7

Advanced Excel for EMIS Coordinators

Links to Activities ACTIVITY 4.1. Links to Activities Links to Activities

Microsoft Certified Application Specialist Exam Objectives Map

Sorting Fields Changing the Values Line Charts Scatter Graphs Charts Showing Frequency Pie Charts Bar Charts...

Introduction to Microsoft Access 2016

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

Report Designer Report Types Table Report Multi-Column Report Label Report Parameterized Report Cross-Tab Report Drill-Down Report Chart with Static

Using Microsoft Access

MS Access Let s begin by looking at the toolbar and menu of Access.

Microsoft Office 2010: Introductory Q&As Access Chapter 3

M I C R O S O F T A C C E S S : P A R T 2 G E T T I N G I N F O R M A T I O N O U T O F Y O U R D A T A

CHAPTER 6 SUMMARY. Objective 1: Identify Good Database Design

Day : Date : Objects : Open MS Excel program. Subject : * Open Excel application. Select : start. Choose: programs. Choose : Microsoft Office

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

Transcription:

Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Program: Microsoft Access Series DESIGNING, BUILDING, AND USING DATABASES (BEGINNING MICROSOFT ACCESS, X405.4) Section 3

AGENDA 6. Introduction to Queries 7. SELECT Query

Introduction to Queries 6.

6. INTRODUCTION TO QUERIES 101 Class database ERD diagram

6.1 WHAT IS A QUERY? 102 So far, we have been concerned with getting data into the database (database design, table design). Now we are going in the opposite direction, retrieving data from the database in a useful and meaningful manner. Query tool is used to retrieve data, it functions like temporary glue to bring data together. Data remains stored in separate tables, but a query can bring data from multiple tables together. User poses a question, query tool scans all necessary tables, fetches the data, and returns a result set of back to the user. Query tool uses a specific language, called SQL (Structured Query Language).

6.1 WHAT IS A QUERY? 103 Query tool not only assembles data and returns it back to the user, queries can also analyze data, such us counting or summarizing data. Additionally, queries can also modify data. Manual filing system does not meet today s data search needs anymore. A computerized filing system makes this process much more powerful. Real power of a database: Capable of examining the data in any way the user requested it.

6.1 WHAT IS A QUERY? 104 Data returned is only in memory, it is not stored in the database. Only instructions how to get the data is stored (SQL command). Queries make the data more human, the scattered data in the tables is a very abstract, though efficient in concept. Query tool is a separate layer to bridge the gap between the raw data in the database and the end-user. Forms/Reports are additional tools to present data to the user. Forms and reports are based on queries. This is another testament how import queries are.

6.2 TYPES OF QUERIES 105 There are many types of queries in MS Access. Different kinds of queries are categorized based on the effect on the data: Select Query Total Query Action Query Crosstab SQL Select Query: Selecting data, specifying sort order, and filtering data. Total Query: Analyzing data by groups of data. Aggregate functions for are sum, minimum, maximum, average, count, standard deviation, and variance. Action Query: Making bulk changes to data or create tables with data. Crosstab Query: Presenting data in a pivot-table like format. SQL Query: Use SQL rather than using the graphical query interface.

6.2 TYPES OF QUERIES 106 SELECT Query Most common type of query. Selects information from one or more tables selecting fields and limiting the number of records by imposing criteria. Sort records in a different way than in a table. Sorting on one or more fields. Performs calculations and creates additional fields based on field values stored in the database (derived or calculated data). Data is returned in the form of a datasheet. It looks exactly like the datasheet view of a table. However, the data in this view is not stored, it is dynamically created with the aid of the query tool. It is called a dynaset.

6.2 TYPES OF QUERIES 107 MS Access comes with a query tool, the query designer tool. Query Designer Tool facilitates creating queries rather than writing SQL.

6.2 TYPES OF QUERIES 108 Single table query based on table tbl_customer. Multi-table query based on tables tbl_customer, tbl_pets, and tbl_visits.

6.2 TYPES OF QUERIES 109 Total Query Special version of a select query. User can analyze data by using the so-called aggregate functions, such as count or sum. Data will be analyzed for the entire table or for groups of records within the table. Count customers within each state. Group By state field, then within each group, use Count function.

6.2 TYPES OF QUERIES 110 Action Queries Action queries can actually make changes to the data, such as adding, deleting, or modifying data as well as creating tables. Action queries make changes in bulk, that is, for an entire group of records or for the entire table. Make-Table Query: Create table and insert data based on a query. Append Query: Insert data into a new or existing table. Update Query: Update existing data. Delete Query: Delete existing data.

6.2 TYPES OF QUERIES 111 Crosstab Query Present and analyze data in a matrix-like format. Row and column headers are generated using data. Intersecting cell value is based on an aggregate function. SQL Query For complex and special queries, the graphical query interface cannot be used anymore. Create a SQL query by typing plain SQL commands. Remember, all queries in MS Access are based on SQL.

6.3 CAPABILITIES OF QUERIES 112

6.3 CAPABILITIES OF QUERIES 113

SELECT Query 7.

7.1 CREATE A SELECT QUERY 114 To create in query in MS Access, follow these steps: Select the Create tab, then click on Query Design in the Queries section. Select the tables necessary for the query in the Show Table dialog box, click on Add, when done click on Close. Add fields, create expressions, specify criteria, and view the results in the dynaset. Save the query as a new query object, use the prefix qry and a meaningful name for the query object.

7.1 CREATE A SELECT QUERY 115 Query wizard offers a variety of query options.

7.1 CREATE A SELECT QUERY 116

7.1 CREATE A SELECT QUERY 117 Query designer interface is divided into two areas, very similar to the table designer interface. The upper area is called the Table/Query Entry area and the lower pane is the Design Grid area. Table/Query Entry Area: Tables and/or Queries are displayed as well as saved relationships. Query Design Grid: Select fields, sort and add criteria. Resize panes by dragging horizontal bar. Resize tables/queries, simply for organizational purposes. Table/Query Entry Area Design Grid Area

7.1 CREATE A SELECT QUERY 118 Rows in Query Design Grid: Field: To select fields (various methods). Table: The table name which a selected field belongs to. Sort: To sort records ascending, descending or not sorted. Show: To show a field in the resulting dynaset. Criteria: To specify one or more criteria for one field or multiple fields. Or: To specify multiple criteria using a Boolean operator of or. The design grid s column represents the fields of the query in the datasheet view once the query is run. The order of fields is from left to right.

7.1 CREATE A SELECT QUERY 119 Each of the output fields has properties, very similar to fields in a table. To access these query field properties: Right-click in the column and select properties from the shortcut-menu. Click in the column and then click the Property Sheet button in the contextual tab Query Tools, Design. Property Sheet Button Short-Cut Menu, Properties

7.1 CREATE A SELECT QUERY 120 Property sheet shows some table field properties which can be overridden at the query level for this particular query only. The field property settings at the table level remain intact.

7.2 WORKING WITH FIELDS IN DESIGN GRID 121 Selecting Fields in Design Grid Area Several methods to add fields from the Query/Table Entry pane to the Design Grid pane. Selecting fields in the tables is similar to selecting files in Windows Explorer. The use of the [Shift] and the [Ctrl] keys is crucial for this operation. Most commonly used method: Select one field in a table, hold the mouse button, and drag the field into the Design Grid pane. Mouse pointer shape changes to a Field Icon (rectangle) with a plus sign. When dragging a selecting field over the Table/Query Entry pane, a circle with a backslash No-Sign, Prohibition Sign is displayed, indicating that you cannot drop a field here. Field Icon with Plus Sign

7.2 WORKING WITH FIELDS IN DESIGN GRID 122 Field Selection Methods: Double-clicking on a field will add this field automatically to the Design Grid pane into the next available column. Selecting multiple adjacent fields: Click with the mouse on the first field, hold down the [Shift] key and select the last field of the range. Click in the orange highlighted area and drag it into the design grid area. Release the mouse button in the Design Grid area. Selecting multiple, non-adjacent fields: Select the first field, then hold down the [Ctrl], then select the other fields. Then drag it into the design grid pane. Release the mouse button in the Design Grid area. Asterisk functions like a wildcard character, double-clicking on it transfers all fields into the Design Grid area. Click in the field row of the Design Grid area, a little drop-down arrow appears to the right. Clicking on this arrow lists all available fields.

7.2 WORKING WITH FIELDS IN DESIGN GRID 123 Managing Fields in Design Grid Area Change the field order in the Design Grid pane: Move the mouse to the top of the column (small gray area above the field row) to be moved. The mouse pointer shape changes to a vertical arrow. Now click and hold the mouse button while you drag the mouse to the left or right. A vertical bar moves with the mouse movement, position the bar to the new position and the release the mouse button. The column will be moved to the new position. Field Selection Arrow Field Selected

7.2 WORKING WITH FIELDS IN DESIGN GRID 124 To remove a field, simply select the column as described above and hit the [Del] button to delete the column. To insert a field, drag a field from the Table/Query Entry pane and place it in the Design Grid pane at the desired location. Existing fields will be moved automatically to the right to accommodate the new field. To show a field in the datasheet view, select the checkbox in the Show row of the Design Grid pane. This checkbox is turned on by default. Field Names/Column Header in a Query When you view a query in datasheet view, the column headers are usually the field names as defined at the table level. Caption property in table design and query design allows you to change column header.

7.2 WORKING WITH FIELDS IN DESIGN GRID 125

7.2 WORKING WITH FIELDS IN DESIGN GRID 126 Export data from a query: Caption property does not get exported, actual field names are used. This is an important fact: Database engine properties vs. application layer properties. Export takes place at the database level. Caption property is part of the application layer.

7.2 WORKING WITH FIELDS IN DESIGN GRID 127 Sorting Data in a Query To sort on a specific field, click inside the sort row of that field. Three choices appear in a drop- down list: Ascending, Descending, and (not sorted). By default, a query is sorted by the primary key of the underlying table. To change the sort order, select one or more fields to be sorted. Sort order will be processed from left to right. Sort Options

7.2 WORKING WITH FIELDS IN DESIGN GRID 127

7.2 WORKING WITH FIELDS IN DESIGN GRID 129

7.3 SIMPLE CRITERIA EXPRESSIONS IN QUERIES 130 To vertically limit the number of records, specify one or more criteria in the criteria row of the query design grid in the query interface. Typical criteria expressions could be: Pets Table: Show me all female pets only. Pets Table: Retrieve a list of pets born before January 1990. Customer and Pets Table: Show me all dogs from customers in California.

7.3 SIMPLE CRITERIA EXPRESSIONS IN QUERIES 131 To enter a criterion for a text field, simply type a value in the criteria row for that field. MS Access will automatically enclose the criterion in delimiters depending on data type of field: Text Quotation marks ( ) Number No delimiters Date/Time Pound symbol (#) The equal sign is the default relational operator; therefore it does not have to be typed in the criteria row. When you enter MS Access displays and retrieves records where Borderville Borderville City field value equals Borderville 1 1 TypeOfCustomer field value equals 1 < 1/1/1998 < #1/1/1998# CustomerSince field value is less than 1/1/1998 Tall Pines Tall Pines City field value equals Tall Pines Between 1/1/1995 AND 1/1/2000 Between #1/1/1995# AND #1/1/2000# CustomerSince field values between 1/1/1995 and 1/1/2000, inclusive

7.3 SIMPLE CRITERIA EXPRESSIONS IN QUERIES 132

7.3 SIMPLE CRITERIA EXPRESSIONS IN QUERIES 133

7.3 SIMPLE CRITERIA EXPRESSIONS IN QUERIES 134 Yes/No fields: Yes values: True, On, Not No, <>No, <No, -1 No values: False, Off, Not Yes, <>Yes, >Yes, 0 A Yes/No field is stored as -1/0 in the database.

7.3 SIMPLE CRITERIA EXPRESSIONS IN QUERIES 135 Creating a query using a Lookup Wizard relationship:

7.3 SIMPLE CRITERIA EXPRESSIONS IN QUERIES 135 Creating a query using a Lookup Wizard relationship: