DB Lab 2 – Relationships and Queries
Name:______
References if Needed
- Information presented in the associated Tour
- Reference Material provided by your Instructor
- Gclearnfree.org lessons
Skills
- Building Relationships between tables
- Building Queries with one or more tables
Assignment
Part 1–Establishing Table Relationships
- You will need a file that is located on our class website. Go to and click on the file called WHP_assignment_2.accdb
- Open the file, it should open in the Access Program (most of you may not have the Access program on your own computers, you will have to do it on a campus computer)
- Once the file opens, click File and choose Save Database As. Save the file to your Documents folder and name it YourNameAccess2 and click Save.
- If the Security Warning appears you can click Enable Content
- What are the Primary Keys in each of these tables?Hint – look at each table in design view
- Artist ______
- Customer Information ______
- Customer Purchases ______
- Recordings ______
- Close each table (Right click the tab and choose close). Go to the Database Tools tab on the Ribbon, and then click Relationships
- Using the Show Tableicon add the following tables (in this order). You will click on each table name and then click Add. Close the show table window when all four are added.
- Customer Information
- Customer Purchases
- Recordings
- Artist
- Establish the following relationships by dragging the correct field name from the first table to the second, release the mouse, double check that the correct columns are listed in the window, and then Click CREATE. The next page shows what it will end up looking like.
- Customer Information table Customer ID to Customer Purchases table Customer ID
- Customer Purchases table Product ID to Recordings table Product ID
- Recordings table Artist Name to Artist table Artist Name
- Right click on the Relationships tab, click SAVE and then Closethe Relationships
- Close any open objects, save if needed
Note that you can now tie a Customer to an Artist through their Purchases. Also note the Primary Key in the Artist table.
Part 2 – Database Queries
Query1–To establish a catalog of the Artists’ work, you’ve been asked to create a report showing each Artist’s Recording’s Titles
- Go to the Create tab on the Ribbon, then click theQuery Wizard icon, choose Simple QueryWizard, and then OK
- Select the Recordings table in the drop down box
- Select, in this order, Artist Name and Title (double click them to add to Selected Fields)
- Click next, use default name of Recordings Query
- ClickFinish
Your results should look like the following (subset shown below, should have 20 records)
- Save and Close the query
Query 2 – WHP wants to send an email to all of the Customers who purchased a Recording by M97. Create a query that provide the email list including the First and Last names and Email Address for just the M97 customers. Don’t worry about duplicate names.
- Go to the Create tab Query Wizard, Simply Query Wizard
- Select the Artist table
- Select Artist Name
- Select the Customer Information table
- Select Customer Name
- Select Email Address
- Click Next twice and then change the query title to Fans of M97
- Click Finish (you’ll have 35 records)
- Switch to DesignView for the query
- EnterM97(don’t type quotes, it will put those in for you) next to Criteria in the Artist Name column of the chart (Note that it shows the Relationships that are being used for the query) See picture on next page
- Switch back to Datasheet view (You should now have a list of 6 customers that have purchased a recording by M97)
Your results should look as follows:
- Saveand Closethe query
- Double click to open the Recordings Query
- Change the “Better Ways” title to Your Name
- Save the query and then Print (File – Print – Quick Print)
- Open the Fans of M97 Query
- Change Dell Roberts to Your Name
- Save the query and then Print (File – Print – Quick Print)
- Close Access.
- Turn in this document stapled with your 2 printouts
Page 1