Exercise 01
Exercise 01
Relationships
EXERCISE
Data Files needed for the Exercise:
LuckyTire.accdb
Customers.csv
Sales.xlsx
Keywords: Tables, Data types, Field Level Constraints, Record level Constraints; Query, Group by query,
Order by query, Simple Join, etc.
Len Phan, the owner of Lucky Tire, has asked you to expand the LuckyTire database to store additional
company data, after seeing how comfortable you are working with Access. He asks you to include
customer and sales information. You decide to add a table for customers, and a third table that tracks
customers tire purchases.
1. Start Access and open the LuckyTire database. Save the database where you save your data files. If
the Security Warning is displayed, click the Options button, click the Enable the content button, and
then click OK.
2. Open the Tires table and in Design View, set the following field properties:
Field Name Data Type Field Size
PartID Text 5
Model Name Text 20
Manufacturer Text 20
Unit Price Currency 2 Decimal Places
Type Text 12
Year Text 4
8. Add the following two records to the Sales table, and then save the table.
Invoice Date CustID PartID Quantity
77340 5/5/2008 50173 Y450T 1
77341 5/5/2008 50211 G812T 1
9. Len has been tracking recent Lucky Tire sales information in an Excel spreadsheet, Sales.xlsx. Append
a copy of the records from Sales to the Sales table.
10. Open the Sales table. Resize all of the columns to their best fit, then save and close the Sales table.
11. Because every sales order needs to have a customer, define the one-to-many relationship between the
primary Customer table and the related Sales table. Select the Enforce Referential Integrity option and
Cascade Update Related Fields option for this relationship.
12. Because every customer sale needs to include a tire model, define the one-to-many relationship
between the primary Tires table and the related Sales table. Select the Enforce Referential Integrity
option and Cascade Update Related Fields option for this relationship.
13. Save the changes to the Relationships Window.
Reporting:
Lucky Tires owner Len Phan is considering opening a new branch in Upland and wants you to provide
information on customers in that city. He also has some tire special coming up and wants you to identify
customers for promotional mailings. In addition, he has some corrections to existing data in the database.
14. Start Access and open the LuckyTire database. Save the database where you save your data files.
15. In the Customer table, change the phone number for Mike Lee to 909-555-4852 and change Maria
Agbayanis street address to 1010 W E St #403. Change the background color to Access Theme 4.
Close the table.
16. In the Tires table, locate Part ID P476X. Check to see if there is any data in the subdatasheet for
P476X, and then delete the record. Close the table.
17. Use Design View to create a query that identifies all of the customers who live in Upland. Select the
First, Last, and City fields from the Customer table. Enter Upland in the City Criteria text box and do
not display this field. Sort the results in alphabetical order by last name. Save the query as Upland
Customers and run the query.
18. After reviewing the list of customers living in Upland, Len wants to see how many customers live in
all of the surrounding towns. Use Design View to create a query that counts the number of customers
in each town. Select the City and CustID fields from the Customer table. Show the Total row in the
query design view. In the Total row, select Group By Count for the CustID field. Save the query as
Town Totals and run the query. Close both queries.
19. For the first promotion, Len wants you to identify customers who have purchased GoodTread Tires.
Using Design View, select the First, Last, Address, City, State, and Zip fields from the Customer table
and Manufacturer from the Tires table. Enter GoodTread in the Manufacturer Criteria text box, and do
not display this field. Show the Total row in the query design view. Sort the records in ascending order
by Zip. Save the query as GoodTread Promotion, and run the query. Close the query.
20. For the second promotion, Len needs the names and addresses of Hondas or Toyotas owners. Copy the
GoodTread Promotion query, and name it Honda-Toyota Promotion. Delete the Manufacturer field
from the query and then delete the Tires and the Sales tables from the query window. Select the Make
field from the Customer table. Enter Honda in the Make Criteria text box, and enter Toyota in the or
text box below. Do not display the Make field. Sort the records in ascending order by Zip. Run the
query. Save and close it.
21. Now Len wants to see the sales figures for each tire manufacturer. Use Design View to create a query
that calculates the total sales per manufacturer. Select the Manufacturer and Unit Price fields from the
Tires table and the Quantity from the Sales table. Use Builder to create a field that displays Unit Price
multiplied by Quantity. Name this field Income. Show the Total row in the query window, and make
the following selections: calculate the average of the Unit Price field; the sum of the quantity field; and
the sum of the Income field. Sort the records in ascending order by the Manufacturer field. Save the
query as Manufacturer Sales and run the query. From the query datasheet window, click the Totals
button in the Records group. Calculate the total quantity and total income of all the manufacturers.
Save and close the query.
22. Close any open tables or queries. Compact and repair the database. Close the LuckyTire database, and
then close Access.