tutorial 9 using action queries and advanced table relationships
TRANSCRIPT
![Page 1: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/1.jpg)
Tutorial 9
Using Action Queries and Advanced Table Relationships
![Page 2: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/2.jpg)
Objectives• Create an action query to create a table• Create action queries to append, delete, and
update data• Define many-to-many and one-to-one
relationships between tables• Learn about joining tables• Join a table using a self-join• View and create indexes for tables
New Perspectives on Microsoft Access 2010 2
![Page 3: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/3.jpg)
Action Queries
New Perspectives on Microsoft Access 2010 3
![Page 4: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/4.jpg)
Action Queries• An action query is a query that adds, changes,
or deletes multiple table records at a time– Make-table query– Append query
• History table– Delete query– Update query
New Perspectives on Microsoft Access 2010 4
![Page 5: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/5.jpg)
Creating a Make-Table Query• Create a select query with the necessary fields
and selection criteria• In the Results group on the Design tab, click
the Run button to preview the results• Switch to Design view to make any necessary
changes to the query. When the query is correct, click the Make Table button in the Query Type group on the Design tab
New Perspectives on Microsoft Access 2010 5
![Page 6: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/6.jpg)
Creating a Make-Table Query• In the Make Table dialog box, type the new
table name in the Table Name box. Make sure the Current Database option button is selected to include the new table in the current database; or, click the Another Database option button and enter the database name in the File Name box. Then click the OK button
• Click the Run button, and then click the Yes button to confirm the creation of the new table
New Perspectives on Microsoft Access 2010 6
![Page 7: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/7.jpg)
Creating a Make-Table Query
New Perspectives on Microsoft Access 2010 7
![Page 8: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/8.jpg)
Creating an Append Query• Create a select query with the necessary fields and
selection criteria• In the Results group on the Design tab, click the Run
button to preview the results• Switch to Design view to make any necessary changes
to the query. When the query is correct, click the Append button in the Query Type group on the Design tab
New Perspectives on Microsoft Access 2010 8
![Page 9: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/9.jpg)
Creating an Append Query• In the Append dialog box, select the table name in
the Table Name box. Make sure the Current Database option button is selected to include the new table in the current database; or, click the Another Database option button and enter the database name in the File Name box. Then click the OK button. Access replaces the Show row in the design grid with the Append To row
• Click the Run button, and then click the Yes button to confirm appending the records to the table
New Perspectives on Microsoft Access 2010 9
![Page 10: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/10.jpg)
Creating an Append Query
New Perspectives on Microsoft Access 2010 10
![Page 11: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/11.jpg)
Creating a Delete Query• Create a select query with the necessary fields and
selection criteria• In the Results group on the Design tab, click the Run
button to preview the results• Switch to Design view to make any necessary changes
to the query. When the query is correct, click the Delete button in the Query Type group on the Design tab. Access replaces the Show and Sort rows in the design grid with the Delete row
• Click the Run button, and then click the Yes button to confirm deleting the records
New Perspectives on Microsoft Access 2010 11
![Page 12: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/12.jpg)
Creating a Delete Query
New Perspectives on Microsoft Access 2010 12
![Page 13: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/13.jpg)
Creating an Update Query• Create a select query with the necessary fields
and selection criteria• In the Results group on the Design tab, click
the Run button to preview the results• Switch to Design view to make any necessary
changes to the query. When the query is correct, click the Update button in the Query Type group on the Design tab. Access replaces the Show and Sort rows in the design grid with the Update To row
New Perspectives on Microsoft Access 2010 13
![Page 14: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/14.jpg)
Creating an Update Query• Type the updated values in the Update To
boxes for the fields you want to update• Click the Run button, and then click the Yes
button to confirm changing the records
New Perspectives on Microsoft Access 2010 14
![Page 15: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/15.jpg)
Many-To-Many Relationship
New Perspectives on Microsoft Access 2010 15
![Page 16: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/16.jpg)
Relationships Between Database Tables
New Perspectives on Microsoft Access 2010 16
![Page 17: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/17.jpg)
Relationships Between Database Tables
New Perspectives on Microsoft Access 2010 17
![Page 18: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/18.jpg)
Defining M:N and 1:1 Relationships Between Tables
New Perspectives on Microsoft Access 2010 18
![Page 19: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/19.jpg)
Make an Alias• Right Click on the table name in the Query
Window then Click on Properties.• Change the name of the table from Property
Sheet.
New Perspectives on Microsoft Access 2010 19
![Page 20: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/20.jpg)
Make an Alias
New Perspectives on Microsoft Access 2010 20
![Page 21: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/21.jpg)
Joining Tables• JOIN can combine two tables.• JOIN Type:
– Inner Join -- fields exist in both tables– Left Outer Join -- all rows in left table with values
from right table where they match– Right Outer Join -- all rows in right table with
values from the left table where they match– Self Join , Joining two fields in one tables.
New Perspectives on Microsoft Access 2010 21
![Page 22: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/22.jpg)
09/11/12.22
JOIN illustration
ID,AGE1,422,193,17
ID,NAME1,JONES3,SMITH
5,BUSTER
![Page 23: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/23.jpg)
09/11/12.23
Inner JOIN
ID,AGE1,422,193,17 1, 42, JONES
3, 17, SMITH
1, 1, 42, JONES3, 3, 17, SMITH
ID,NAME1,JONES3,SMITH
5,BUSTER
![Page 24: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/24.jpg)
09/11/12.24
Left Outer JOIN
ID,AGE1,422,193,17 1, 42, JONES
2, 19, null3, 17, SMITH
ID,NAME1,JONES3,SMITH
5,BUSTER
![Page 25: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/25.jpg)
09/11/12.25
Right Outer JOIN
ID,AGE1,422,193,17 1, 42, JONES
3, 17, SMITH5, null, BUSTER
ID,AGE1,422,193,17
ID,NAME1,JONES3,SMITH
5,BUSTER
![Page 26: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/26.jpg)
Joining Tables• In the Query Design Window, Insert the tables
then right click on the relationship , Click on “Join Properties” .
New Perspectives on Microsoft Access 2010 26
![Page 27: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/27.jpg)
Joining Tables
New Perspectives on Microsoft Access 2010 27
![Page 28: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/28.jpg)
Joining Tables
New Perspectives on Microsoft Access 2010 28
![Page 29: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/29.jpg)
Joining Tables• An inner join is a join in which the DBMS
selects records from two tables only when the records have the same value in the common field that links the tables
New Perspectives on Microsoft Access 2010 29
![Page 30: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/30.jpg)
Joining Tables• An outer join is a join in which the DBMS
selects all records from one table and only those records from a second table that have matching common field values
New Perspectives on Microsoft Access 2010 30
![Page 31: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/31.jpg)
Creating a Self-Join• Click the Create tab on the Ribbon• In the Queries group on the Create tab, click
the Query Design button• In the Show Table dialog box, double-click the
table for the self-join, double-click the table a second time, and then click the Close button
• Click and drag the primary key field from one field list to the foreign key field in the other field list
New Perspectives on Microsoft Access 2010 31
![Page 32: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/32.jpg)
Creating a Self-Join• Right-click the join line between the two
tables, and then click Join Properties to open the Join Properties dialog box
• Click the first option button to select an inner join, or click the second option button or the third option button to select an outer join, and then click the OK button
• Select the fields, specify the selection criteria, select the sort options, and set other properties as appropriate for the query
New Perspectives on Microsoft Access 2010 32
![Page 33: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/33.jpg)
Creating a Self-Join
New Perspectives on Microsoft Access 2010 33
![Page 34: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/34.jpg)
Viewing a Table’s Existing Indexes• Open the table in Design view• To view an index for a single field, click the
field, and then view the Indexed property in the Field Properties pane
• To view all the indexes for a table or to view an index consisting of multiple fields, click the Indexes button in the Show/Hide group on the Design tab
New Perspectives on Microsoft Access 2010 34
![Page 35: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/35.jpg)
Viewing a Table’s Existing Indexes
New Perspectives on Microsoft Access 2010 35
![Page 36: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/36.jpg)
Creating an Index• Open the table in Design view• To create an index for a single field, click the
field, and then set the Indexed property in the Field Properties pane
• To create an index consisting of multiple fields, click the Indexes button in the Show/Hide group on the Design tab, enter a name for the index in the Index Name box, select the fields in the Field Name box, and then set other properties as necessary for the index
New Perspectives on Microsoft Access 2010 36
![Page 37: Tutorial 9 Using Action Queries and Advanced Table Relationships](https://reader036.vdocuments.net/reader036/viewer/2022081504/56649f135503460f94c27b96/html5/thumbnails/37.jpg)
Creating an Index
New Perspectives on Microsoft Access 2010 37