Docsity

Normalizing a Database and Running Queries in Access: A Lab Exercise - Prof. Carl Rebman, Lab Reports of Management Information Systems

Toggle sidebar
bg1
ITMG 100 ACCESS LAB EXERCISE #2
By now you should have figured out how to normalize a database both from in class and on your own. Download
and save the Harkins.mdb file from the ITMG 100 Course Website (located under the access hyperlink from the
schedule page). Upon download—proceed to create the necessary relationships as to normalize the database
(HINT: Remember that a primary key is in bold for each table and that a primary key can also be listed in another
table which is then known as a foreign key)
All About Queries
Now that we have fixed the Harkins database the upper management is very interested in the learning about the
information lost as it needs to make many important decisions. Some decisions are about what theater zones are
producing best, others are about what types of movies are doing better than others. Since you have been exposed
to access you know that these answers can be obtained by running queries of the database. Let’s start with some.
We will start with an easy query for review-it is also referred to as either a simple or select query.
Go back to the query option in your access database. Again click on query wizard and select movie_type so that it
appears on the right hand side. This time notice that you can select from other tables. Once are done selecting
movie_type search for the sales table and select the item sales so that it appears on the right. Upon completion hit
next and then notice you have two options in the dialog box—one that allows you to select detailed or summary
reports. Click on the summary selection and then hit the summary options box. A new screen will come up asking
you what type of summary options you want—select sum and then hit OK. The next screen will ask you to name
your query and ask how you want to open it—just select the option that says to run the query upon hitting Finish. If
successful you will a listing of all of the different movie types and the sum of their sales. Which movie typed
produced the most sales?
Sorting Query Fields
Lets move to one more little advanced step—learning to sort within a query. Right Click on the movie type query
and select the sort ascending option A-Z. Save your results as Movie_Query_1.
Creating a Select Query
Often times there are cases when you wish to know an answer based on specific criteria. For example, say you
want to know the sum of sales for a particular week. This particular exercise will introduce you how to create this
type of query—first as a hard-coded entry. Then the second part will show how you can create a dialog box to come
up to entertain many different types of questions (i.e. Instead of always showing week 1, the person will be able to
enter in a specific week of their choosing. This time we are going to create a query in design view and not use the
query wizard. To accomplish this task complete the following tasks.
QUESTION ASKED “WHAT WHERE THE TOTAL SUM OF TICKET SALES FOR WEEK 3?”
1. Close out of all table and query views that you might have open.
2. Click on queries in your access view.
3. Select the create a new query in design view.
4. Select the sales tables.
5. Select the week_ID field in the sales table and drag it to the query column.
6. Repeat Step 5.
7. Select the sales field and drag it to the query column.
8. Hit the SIGMA button on the toolbar.
9. Underneath the first week_ID column in the row marked total—change GROUP BY to WHERE.
10. Underneath the criteria row type in the number 3 underneath the same column that you used in step 9.
11. Hit the exclamation mark to run the query. If successful your answer should be $12,874,056. You should
save your query as movie_query2.
ONE STEP FURTHER
This was great that you were able to find the answer for week 3. But what if you needed the answers for other
weeks? Do you really want to recreate new queries for each week? Probably not, and why should you when
you don’t have to. All you need to do is one little step listed below.
Instead of having a number 3 in your criteria box lets change it to the following syntax: [which week?]
pf2

Partial preview of the text

Download Normalizing a Database and Running Queries in Access: A Lab Exercise - Prof. Carl Rebman and more Lab Reports Management Information Systems in PDF only on Docsity!

ITMG 100 ACCESS LAB EXERCISE

By now you should have figured out how to normalize a database both from in class and on your own. Download and save the Harkins.mdb file from the ITMG 100 Course Website (located under the access hyperlink from the schedule page). Upon download—proceed to create the necessary relationships as to normalize the database (HINT: Remember that a primary key is in bold for each table and that a primary key can also be listed in another table which is then known as a foreign key)

All About Queries

Now that we have fixed the Harkins database the upper management is very interested in the learning about the information lost as it needs to make many important decisions. Some decisions are about what theater zones are producing best, others are about what types of movies are doing better than others. Since you have been exposed to access you know that these answers can be obtained by running queries of the database. Let’s start with some. We will start with an easy query for review-it is also referred to as either a simple or select query. Go back to the query option in your access database. Again click on query wizard and select movie_type so that it appears on the right hand side. This time notice that you can select from other tables. Once are done selecting movie_type search for the sales table and select the item sales so that it appears on the right. Upon completion hit next and then notice you have two options in the dialog box—one that allows you to select detailed or summary reports. Click on the summary selection and then hit the summary options box. A new screen will come up asking you what type of summary options you want—select sum and then hit OK. The next screen will ask you to name your query and ask how you want to open it—just select the option that says to run the query upon hitting Finish. If successful you will a listing of all of the different movie types and the sum of their sales. Which movie typed produced the most sales? Sorting Query Fields Lets move to one more little advanced step—learning to sort within a query. Right Click on the movie type query and select the sort ascending option A-Z. Save your results as Movie_Query_1.

Creating a Select Query

Often times there are cases when you wish to know an answer based on specific criteria. For example, say you want to know the sum of sales for a particular week. This particular exercise will introduce you how to create this type of query—first as a hard-coded entry. Then the second part will show how you can create a dialog box to come up to entertain many different types of questions (i.e. Instead of always showing week 1, the person will be able to enter in a specific week of their choosing. This time we are going to create a query in design view and not use the query wizard. To accomplish this task complete the following tasks. QUESTION ASKED “WHAT WHERE THE TOTAL SUM OF TICKET SALES FOR WEEK 3?”

  1. Close out of all table and query views that you might have open.
  2. Click on queries in your access view.
  3. Select the create a new query in design view.
  4. Select the sales tables.
  5. Select the week_ID field in the sales table and drag it to the query column.
  6. Repeat Step 5.
  7. Select the sales field and drag it to the query column.
  8. Hit the SIGMA button on the toolbar.
  9. Underneath the first week_ID column in the row marked total—change GROUP BY to WHERE.
  10. Underneath the criteria row type in the number 3 underneath the same column that you used in step 9.
  11. Hit the exclamation mark to run the query. If successful your answer should be $12,874,056. You should save your query as movie_query2.

ONE STEP FURTHER

This was great that you were able to find the answer for week 3. But what if you needed the answers for other weeks? Do you really want to recreate new queries for each week? Probably not, and why should you when you don’t have to. All you need to do is one little step listed below. Instead of having a number 3 in your criteria box lets change it to the following syntax: [which week?]

When you have completed that task, hit the exclamation mark and run the query again. This time you should get a dialog box that asks you a question ‘which week?’ and after your response produces an answer. Execute the query and write down your answers to the different weeks listed below. When finished save your query as movie_query3. Week 2 ___________ Week 7 ___________

Completing/Developing a AND Criteria Query

There comes a time when you wish to sort on one specific field and on another specific field. For example if we wish to determine what the sales of a particular movie in a particular zone was. Again this time we are going to create a query in design view and not use the query wizard. To accomplish this task complete the following tasks. QUESTION ASKED “WHAT WHERE THE TOTAL SUM OF TICKET SALES FOR THE MOVIE ‘HOSTAGE’ IN THEATER ZONE 3?”

  1. Close out of all table and query views that you might have open.
  2. Click on queries in your access view.
  3. Select the create a new query in design view.
  4. Select the movie, theater, and sales tables.
  5. Select the movie_name, theater_zone, and sales fields from their respective tables and drag them into their respective columns.
  6. Enter in the name hostage under criteria underneath the movie name column
  7. Enter in the number 3 underneath the theater zone column.
  8. Also select the SIGMA button to create the additional row in design view.
  9. Select the sum option under sales.
  10. View your results after hitting the exclamation mark. Does it list $ $49,175,824.00—if so you have executed the AND Query Correctly_save this as movie_query

Completing/Developing a OR Criteria Query

There are also times where you wish to sort on a condition where the answer can be determined by an OR condition. For example, perhaps you wish to know the answer to which movies had either the highest or the lowest sales for a given week. In this example will be wanting to find the answer to this specific question “What where the movies that had sales less than100,000 and more than 1,000,000 in week 3”.Again we will engage in creating a query in design view. To accomplish this task complete the following tasks:

  1. Close out of all table and query views that you might have open.
  2. Click on queries in your access view.
  3. Select the create a new query in design view.
  4. Select the movie, week, and sales tables.
  5. Select the movie_name, week_ID, and the sales fields from their respective tables.
  6. Enter in the number 3 underneath the week_ID column_you will also want to hit the SIGMA button and select the ‘WHERE’ option in the TOTAL row in the same column.
  7. Enter the following under criteria row under the sales column a. In the first row type <100, b. In the second row type >1,000,
  8. If executed correctly, your query result in listing five movies. Save the query as movie_query5.

Exporting to Excel

Access like all the other office products integrate very well with each other. In this example we wish to take our query results and export them to Excel so that we can make a chart of the answer. With the query still open (after being executed) select Tools on the top bar, and then select Office Links (hint you may have to select the double arrows to expand menu options). You should notice that you have some options to merge the data with work, publish it with word, or analyze it with Excel. Select the last option. If successful Excel will open up and you can then make a chart out of the data.

FINISHING UP

Save your file as your_last_name_harkins_a2.mdb and email that file to me at [email protected].