Title of lab: Microsoft Access 2010 IST 195 Lab 11: MS Access Learning goal: Databases are collections of information, and database programs are designed to maintain data in structured tables. In this lab you will obtain skills necessary to work with MS Access databases and understand the concepts of: queries, referential integrity and relationships between tables. Submission Instructions: You are required to submit one MS Word (.docx) file to blackboard by 4:59PM on Friday. Be sure that the file name of your submission includes your last name (i.e. lab11dziedzic.docx). To complete the lab, you must complete each of the following parts listed below: 1. SQL Query Code 2. Description of SQL Query 3. Contents of NEWDISK Table 4. Error Screenshot 5. Report Screenshot Downloading your Lab 11 Template document Download the Lab 11 Template.docx document for blackboard. Be sure to save and rename the file LAB11(yourlastname).docx (to download the file you may need to right click on the file and click, Save Target As. ) Downloading / Opening your MS Access Database You will need to download the MS Access database (Lab11.accdb) (to download the file you may need to right click on the file and click, Save Target As. ) from blackboard in order to complete this lab. Note: Make sure you download and save the database to your desktop and not to just try and open it from blackboard. IMPORTANT: If you are working from home and are not able to open the database, you must use the VPN facility, or come to the lab to complete the assignment. GA s will not address emails relevant to the lab you should come into lab if you have questions. General Note: The area at the top of any Microsoft Office program (as shown below) is called the ribbon. We will refer to this many times throughout the lab. Step 1: Opening Access Database a. From the Start Menu, click All Programs > Microsoft Office > Microsoft Access 2010 1
b. On the left side, click the Open button c. Select the Lab11.accdb IST 195 Lab 11: MS Access Note: You may need to click enable content at the top when you try and open the file because of security measures built into Access. Creating Your Queries Step 1: Creating your Songlist Query In this step you will create the SONGLIST query using the Create option from the tool bar and then using Query wizard. Below are the steps you will need to complete to create this query. 1. Click on Create and then on Query Wizard; Create Query wizard 2. From New query window, select Simple Query Wizard and hit OK Note: In the results of this query, the data will contain all of the songs in the Database. For each song, you will need to make sure you include the Genre from the Genre Table, the Artist Name from the Artist table and the Song Title from the Songs Table. 3. You will see a window asking you Which fields do you want in your query. Note: You will need to first select the table that you will be pulling the data from under the Tables/Queries dropdown. Once you select your table, the Available Fields will refresh, which you can then select the field you will use for your query 2
4. For each table, select the appropriate field from the list of AVAILABLE fields, and click on > to move the field into selected field column. Now choose the next table and repeat the above steps for all the three tables and then select next. Take note of the Table and the Field a. Artists Table: Select ArtistName b. Genres Table: Select Genre c. Songs Table: Select SongTitle Note: Make sure that you select the tables and the fields in the above order. Once you have all of the fields selected, from their respective tables click NEXT. 3
5. In this step select Detail (shows every field of every record) and select next. 6. Title your query, Songlist Query, click Open the query to view information radio button and select Finish. 7. Once the query has finished running, you will be provided with the query s results. Note: The output of your query should have 45 records. (This number will be displayed at the bottom of the screen next to the word: Record) Step 2: Creating a new table from your Songlist Query In this step you are going to add selection criteria so that only songs with an available MP3, and a rating of greater than 4, are listed. The results of this table will create a new table in the same Access database. To do this, you will use your existing Songlist query as the starting point. 1. From the left panel, select the Songlist query (If the query is not visible, click on the pull down menu that says Tables, click on Queries). The screen should look as below; Verify the output by checking that there are 45 records 2. Click on Songlist Query (when selected it will highlight in yellow). Then right click on the Songlist Query and select Design View. 3. Click and drag: Artists table: ArtistName to the first column (Should already be there) Genres table: Genre to the second column (Should already be there) Songs table: SongTitle to the third column (Should already be there) SongRating to the fourth column (add) HaveMP3 to the fifth column in the table (add) When complete, your Songlist Query should look similar to that shown below. Note: If you have fields already populated, you can change the row to match the data items above by selecting either the Field and/or Table cells and selecting the item and/or table needed 4
4. Now deselect the Show checkbox under the SongRating and HaveMP3, as we do not want to show these fields in this query s results. 5. Next add the following Criteria to the SongRating and HaveMP3. For SongRating add > 4 into the Criteria field by just typing in the >4. For HaveMP3 add Yes into the Criteria field by just typing in Yes (CaSe SeNsiTive) When you re done, your results should look like the screenshot below: Note: Even though we ve just chosen to not show these fields, we can still place a Criteria for the results shown in our query. 6. SAVE your work at this point by selecting the Menu icon at the top left for the program and selecting Save. 7. Now click on the RUN button in the Ribbon located in the results section of the Design tab. You should see a result that looks similar to the following: 8. Save the results of this changed query to a new table titled NEWDISK. To create the new table: a. Select Home along the top of the header. b. Click on drop down located below the View icon c. Select DESIGN VIEW d. In the Design Tab: Click on MAKE-TABLE on the Query Type group 5
e. Following window will appear; enter the Table Name: NEWDISK and create it in the Current Database f. In the Make Table Window, Click OK. g. Now click on the RUN button in the Ribbon h. When asked to confirm that You are about to paste 7 row(s) into a new table ; Click Yes i. To review the query that you just made in SQL form, from the ribbon, pull down the menu next to View and then select SQL View Step 3: Update your lab document The steps below are what you will need to update into your LAB11(yournetID).docx file. 1. Under SQL Query: Copy the SQL query text that you created and paste it into your Word a. To view your SQL query text, select the dropdown box under the View icon (on the Home tab) and select SQL View 2. Under Description of SQL Query: provide a description in 2-3 sentences of what the SQL statement you just created does. a. Hint: Talk about the process that you just went through to create the SQL statement. You should think about how through Access you created constraints and extracted a specific bit of information from a larger dataset. 3. Under Content of NEWDISK Table: Copy the contents of the NEWDISK table and paste it into your document. Make sure to title this section NEWDISK Table. Note: To change between the query and table, select the dropdown next to Queries and then select Tables. Then locate the NEWDISK table and: 6
a. Right click the top-left corner on NEWDISK table b. Select Copy c. Then go to your word file and paste (Ctrl-V) the table 4. Save the document and continue to the next step. Exploring Relationships In this portion of the lab, you will modify the relationship between the GENRES table and the SONG table so your database allows you to delete a GENRE, which currently is used in the SONG table. Step 1: Locate and Open the Genre table 1. Open the Genres table 2. Scroll to the row with the Genre RAP. 3. Select that record by clicking once in the selection area (the area to the left of the record see below) 4. From the RECORDS group in the top, hit the Delete button on your keyboard 7
This is the selection area. 5. You should receive an error message when you try to do this step. 6. Take a screenshot of this ERROR message. 1. Note: To take a screen shot use the Snipping Tool on Windows. 7. Update your lab document under Error Screenshot with the screenshot of the Error message Step 3: Deleting a Genre Before being able to remove the Rap record, you must either delete all corresponding records in the Artist database where the artist is a Rap artist OR you can have access do the work for you. To get Access do, you must close the Genres table before proceeding. 1. Close your Genre table (There should be an X in the top right of the Genres window within Access) 2. From the ribbon select DATABASE TOOLS tab and then RELATIONSHIPS. 8
3. Right-click on the relationship line that connects the Genres Table to the Artists Table and Select EDIT RELATIONSHIPS. 4. In the edit relationships box, check the box next to Cascade Delete Related Records. Click OK 5. Next close only the Relationships window and then open the Genres table by double-clicking on the table listed on the left of the screen. 6. Now try to delete the record for RAP again. (see steps above if you forget how) If prompted with an error/confirmation message that s ok. Read the error message and click Yes 7. The cascading delete in the relationship should have removed all corresponding RAP artists as soon as you delete RAP as a valid GENRE. Note: To check that the Rap artist was removed from the Artist table, open it up and see if you can find an artist with the genre of Rap. 8. SAVE your database and double check your lab document to make sure that you have completed all required section up to this point. Creating a Report In this portion of the lab, you will create a printable report that will generate a list of all of the songs available within your database. 9
Step 1: Select Report Wizard from the Create menu 1. On the CREATE tab (on the ribbon), click the Report Wizard in the Reports group. 2. Select Table: Songs from the pull-down menu under Table/Queries. 3. Select the fields SongID, SongTitle, ArtistName & SongRating and move them over by clicking on the > symbol, once all of them are moved, click Next to continue. 4. You will now be prompted to assign a grouping level to your Song List Report. Note: This provides a method for organizing your report by field. 5. Select the SongID field to add a grouping level based on that field. Use the > symbol to confirm your grouping selection (as shown below). Click Next to continue. 6. Now you have the option to sort records in either ascending or descending order based on their field. 7. Sort Song Ratings in descending order by selecting the appropriate field in the drop down menu, and then changing Ascending to Descending (As shown below). Click NEXT to continue. 10
Ascending is the default. Click on the button to change it to Descending. 8. Now you have the option of selecting a layout for your report. Blocked reports will contain bordering; outlined reports will outline fields, etc. 9. For the purpose of this select the Block layout. 10. To make sure all fields fit on one page select the Portrait Orientation option. 11. Select (if not already selected) Adjust the field width so all fields fit on page 12. Click Next to continue. Be sure to select block 13. Rename your report MySongs, make sure the Preview the Report is selected, and click Finish. 14. Make sure that you are able to see the following fields on your report: 1. Song ID 2. Song Rating 3. Song Title 4. Artist Name 11
Note: If you don t have all of these fields, ask one of the GA s to help you locate them. Step 2: Update your lab document The steps below are what you will need to update into your LAB11(yournetID).docx file. 1. Save the changes made in the report. 2. Take a screenshot of the report you created and add it to your lab document under the section, MySongs Report. When you have finished adding the MySongs Report to your LAB11(yournetID).docx file please double check that you have filled in all 5 of the required sections, save the document, and upload it to Blackboard. 12