440 likes | 601 Views
PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory Chapter 13 Sort and Query a Database. Objectives. Open an Existing Database Create Table Relationships Sort Records in a Table Create a Query in Design View Create a New Query From an Existing Query.
E N D
PowerPoint Presentation to Accompany GO! with Microsoft® Office 2007 Introductory Chapter 13 Sort and Query a Database
Objectives • Open an Existing Database • Create Table Relationships • Sort Records in a Table • Create a Query in Design View • Create a New Query From an Existing Query
Objectives • Sort Query Results • Specify Criteria in a Query • Create a New Table by Importing an Excel Spreadsheet • Specify Numeric Criteria in a Query • Use Compound Criteria
Objectives • Create a Query Based on More Than One Table • Use Wildcards in a Query • Use CalculatedFields in a Query • Group Data and Calculate Statistics in a Query
Create Table Relationships • Access databases are relational databases because the tables in the databases can relate to each other. • Common fieldsare fields that include the same data in more than one table. • Place common fields in tables that are related, then define the relationship.
Create Table Relationships • Both tables include common fields • In first table, primary key • In second table, foreign key • Referential integrity ensures the validity of the data between related tables. • Join line between the two tables show the one-to-many relationship.
Create Table Relationships One-to-Many indicated
Sort Records in a Table • Sorting is the process of arranging data in a specific order. • Ascending–A to Z or lowest number to highest • Descending–Z to A or highest number to lowest • To sort records, click the arrow to the right of the field name.
Sort Records in a Table • To sort on two or more fields • Identify the outermost sort field (first level of sorting) • Identify the innermost sort field (second level of sorting) • Sort the outermost field first; then sort the innermost field.
Create and Use a Query • A query retrieves specific data from one or more tables. • Query means to ask a question. • Data sources are the table or tables from which queries get their data. • Access provides a wizard to walk step by step through the query process. • The wizard involves choosing the data source and fields.
Create and Use a Query • On Ribbon, click Create tab. • In Other group, click Query Wizard. • In New Query dialog box, click Simple Query Wizard, then OK. • In dialog box, select table. Select fields. • Follow wizard. Name query with a meaningful name.
Create a Query in Design View • Queries created in Design view can be more complex. • Click Create tab on Ribbon, in Other group, click the Query Design button. • In the Show Table dialog box, click the first table, click the Add button, then close the dialog box. • Query window: field list (upper pane) and design grid (lower pane).
Create a New Query From an Existing Query • It is a good idea to save your queries. It is very likely you will need to ask the same question again. • Open a previous query. • From the Office menu, click Save As. • Save with a new name.
Sort Query Results • Results of a query can be sorted. • The process is similar to sorting a table. • Open a saved query. • From Office menu, click Save As. • Save with new name.
Sort Query Results • In Design view sorting can be done on two non-adjacent fields. • One field can be sorted in ascending order and the other in descending order. • Fields that have Sort designations are sorted from left to right.
Specify Criteria in a Query • Queries can locate information based on criteria specified as part of the query. • Criteria are conditions that identify the specific records you are looking for and enable you to ask more specific questions. • You do not have to have every field in the query display in the results. • In the Show row, click the box to clear the criteria you do not want to be shown.
Specify Criteria in a Query • To locate records where specific data is missing, use is null as a criteria. • To locate records where a value has been entered, use is not null as criteria.
Create a New Table by Importing an Excel Spreadsheet • Many users track their data in an Excel spreadsheet. • Sorting and filtering capabilities are useful for simple databases. • Excel is limited to one table and cannot relate data from multiple spreadsheets. • Data from Excel spreadsheets can become Access tables by importing the spreadsheet.
Specify Numeric Criteria in a Query • Criteria can be set for fields that contain numerical data. • Set the appropriate data type for fields that will contain numbers, currency, or dates so that mathematical calculations can be performed.
Specify Numeric Criteria in a Query • Comparison operators can be used to evaluate each field value. • Same = • Greater than > • Less than < • In between a range (Between...And) For example - Between 08/01/09 And 09/30/09
Use Compound Criteria • Compound criteria is used for specifying more than one condition in a query. • Logical operators ANDandOR are compound criteria. • AND displays records that meet both parts of the specified criteria. • OR displays records that meet either part of the criteria.
Create a Query Based on More Than One Table • In relational databases, information can be retrieved from more than one table. • Tables are joined by relating primary key field in one table to foreign key field in the other table. • Add the required fields. • Set the criteria on the Criteria row for the first criteria. • Set the second criteria on the OR row.
Use Wildcards in a Query • Wildcard characters serve as a placeholder for one or more unknown characters in the criteria. • The asterisk (*) represents any group of characters. • The question mark (?) is used to search for unknown single characters. • Access adds the word like at the beginning of the criteria.
Use Calculated Fields in a Query • Queries can create calculated values. • First, name the field that will store the calculated values. • Second, write the expression that will perform the calculation. Each field name used in calculation must be enclosed within its own pair of square brackets, [ ]. • Zoom dialog box display gives you working space so you can see your calculation as you type it.
Group Data and Calculate Statistics in a Query • You can perform statistical calculations known as aggregate functions on a group of records. • Examples: AVG, SUM, MAX, and MIN • The aggregate functions can also be used to calculate totals by groups of data.
Covered Objectives • Open an Existing Database • Create Table Relationships • Sort Records in a Table • Create a Query in Design View • Create a New Query From an Existing Query
Covered Objectives • Sort Query Results • Specify Criteria in a Query • Create a New Table by Importing an Excel Spreadsheet • Specify Numeric Criteria in a Query • Use Compound Criteria
Covered Objectives • Create a Query Based on More Than One Table • Use Wildcards in a Query • Use Calculated Fields in a Query • Group Data and Calculate Statistics in a Query