COMP1115 Week 11 Microsoft Access Relationships and Queries Part 1 W19
COMP1115 Week 11 Microsoft Access Relationships and Queries Part 1 W19
Querying a Database
a query is a question you ask about data stored in a
database
you tell Access what fields you need and what criteria
employer ID
employer name
city
contact first name
contact last name
web site information
for each record in the Employer table
Microsoft Access – Tutorial 3
Query by Example (QBE)
open the Northeast database we created last week
show the Employer Table and the close the Show Table
dialog box
maximize the Query window
Microsoft Access – Tutorial 3
Query by Example (QBE)
you will see the field list in a box entitled Employer (the
table name)
you can double-click or drag fields to the design grid
in the design grid, you include the fields and record selection
datasheet
click the View button to return to Design View
click the Save button on the toolbar and name the query
EmployerAnalysis
Microsoft Access – Tutorial 3
Updating Data using a Query
return to the Datasheet view
website
change the Contact person for Alpine Touring Center
been made
close the Employers table
Microsoft Access – Tutorial 3
Table Relationships
remember that Access is a relational database management
system
relationships are created among tables by using common
fields
this process is often called a join
when you join tables with a common field, you can extract
relationship
this is the Employer table
the related table is the many table
this is the Position table
Microsoft Access – Tutorial 3
One-to-Many Relationships
orphaned records can be created when inconsistencies
Relationships window
Database Tools > Relationships
visible
Microsoft Access – Tutorial 3
Defining Relationships
check Enforce Referential Integrity
symbols on it
button
double-click the word clerk in one of the Position Title
records
click the Filter by Selection button (located in Home > Sort
Position is selected
add all the fields by clicking >>
select Openings
now add EmployerName, StateProv, ContactFirstName,
make sure the Detail radio button is selected and click Next
again
name the Query HousekeepingPositions and click the Modify
run the query and Save (File > Save Object As) it as
HighWageAmounts
Microsoft Access – Tutorial 3
Using Multiple Selection Criteria with the And operator
open the HousekeepingPositions query in Design View
run the Query and you’ll see results that match both criteria
use the Employer and Position tables and add the following
Save it as HoursorExperience