Lab 7 : The Blue Lab
Introduction to Databases : MS Access
In a nutshell, a database is a repository for data, provides convenient ways to access and query the data. A database differs from a spreadsheet in that it is not meant to involve intensive computation, instead it focuses on the efficient storage and retrieval of data.
In a database data is stored in one or more tables. A table consists of many components called records. Each record consists of one or more fields. These fields are the *actual* data stores. A database is a great example of abstractions as layers are added to improve the organization of the data.
Generally speaking, there are a couple of ways that databases can be structured.
Each record in your database is much like an element in a hash table. Each hash table has elements, and each element must have a unique key associated with it. This key guarantees that Access can distinguish records from one another. Text fields, such as names, are bad primary keys, because two objects could have the same value in the text field (two people can have the same name). It is better to use some sort of ID number (like a social security number). When Access adds a primary key field, it will be a number field that automatically increments itself. The field will label the first record in the table 1, and count upward from there. This automatically generated key is what is used as the identity for a field in each of the tables.
The major tasks that can be performed with a database are data entry, data retrieval, and data display. Microsoft Access's tools to accomplish these tasks are:
Queries are used to find specific data in the database. With a query, the database is asked a question about the data that it contains, the database then returns an answer to the query. This is one of the most important and often the most complex features of a database.
Open up Microsoft Access and then choose the open option. Open up the file that you have just downloaded. Once you have accomplished this step give yourself a huge pat on the back. You should see something like this on your screen.

Let us study the picture in some more detail. There are various tabs in the window. The tabs that we will be concerned with are the Table tab, Query tab and the Report tab.
First click on the table tab. Tables as mentioned before are the main data storage elements in the database. The three tables that are present in this database are:
You can select one of these tables followed by a click on the open option on the left of the window. Peruse these tables for information on the great one.
There a few fundamentals that you need to grok before performing queries in Access. The baby steps required to create a new query are listed below:
After you have created the new query and added the tables, you will see a window with two main sections. The upper section contains miniatures of the tables that you selected for the query. The lower section is where you insert fields and criteria for your queries.

The database you are using in this lab has three tables. The Reprise Albums table contains three fields the ProductID field (the unique key), album name and Year of release. The Song List table contains the ID (the unique key), an Album ID (the ProductID from the aforementioned table) and the songs from the respective album. The Covered Songs table contains the unique ID, the name of the song that was covered, the year that the song was covered and the name of the artist who covered the song.
The three tables allows the Joni-Base to contain disparate kinds of data. By joining/linking our tables we can get them to work together. All you have to do to join the tables is click on the field name in one table and drag it over to the like field name in the other table. When you let go of the mouse button, a line will appear, linking the two tables. To delete a link, right-click on it and choose delete from the pop-up menu.
Join the tables EXACTLY as shown in the picture above so that the ProductID field from the Reprise Albums table is linked to the Album ID field in the Song List table and the Song Name field in the Song List table is linked to the Song Covered field in the Covered Sings table.
You only need to be concerned with a few of the cells in the lower grid. The first one is labeled Field. In Field you specify the field you want to use in your query. The Sort cell is where you select the order in which you want the data from the query to be displayed. Placing an 'X' in the Show cell will cause that field to be displayed when you execute the query. The cell you will use the most is the Criteria cell. This is where you will specify the data attributes by which you are searching.
Saving a query in Microsoft Access is simple. Unlike some other database programs, Access uses one file to store all of the tables, form, reports, queries, etc. After you have run a query and have the results you wanted to obtain, all you have to do is go to the File menu and choose Save. This gives you the opportunity to name and save your query.
Let us walk through the queries that you need to conduct to complete this Mitchellicous lab.
Before you conduct each of these queries remember that you need to create a new query. This is done by selecting the query tab and then hitting new.
Query 1:Query the database for the names of all the songs that were originally sung by Joni and have been covered by other artist. Display the albums, the name of the songs and the names of the artists.
Since you have three tables in the upper portion we will select three fields.
After you have selected the fields go to the Query menu and select the run option. If you have followed the steps to the letter you will get a list of all the covered Joni Mitchell songs.
Select save from the File menu and save this query as Joni Cov Songs.
Query 2:Query the database for the names of all the songs that were originally sung by Joni and have been covered by Tori Amos. Display just the name of the song.
Go through the steps to add and join tables again
Since you have three tables in the upper portion we will select three fields.
We need to make one minor modification as we are searching for one specific artist.
In the Criteria field type *tori amos*. This will narrow the search to just Tori
After you have selected the fields go to the Query menu and select the run option. If you have followed the steps to the letter you will get one song that Tori Amos has covered that was sung by Joni Mitchell.
Remember that I want just the name of the song, hence you will need to select/de select the show boxes as you see fit.
Select save from the File menu and save this query as A Case of Joni
Query 3:Query the database for the names of all the songs that have been covered from the album Blue. Display the names of the songs and the artists that covered them. Please don't display the name of the album. If you understood how the previous two parts work this should be a piece of cake for you.
Select save from the File menu and save this query as Kind of Blue.Creating a report is a practical way to represent your sorted data as document suitable for printing. You can also print forms or tables, but reports give you more control over how you display and organize your data. We will now create a report that will display
Report 1:To create a new report:
Choose the Report tab and click on the New button.
Click on
the Report Wizard in the upper list menu.
Choose a field from the Table/Queries list. For this report select
Kind of Blue. Make sure to add all the available feeds into the report.
Follow the directions in the wizard and feel free to exercise your artistic
abilities.
Click on the Finish button to view the report
To save a report, go to the File menu and click on save. Save the report as Blue-Report.
Forms are one of Microsoft Access' most versatile tools. You can view all the fields for one record in Form view, or you can view all the records at one time in the Data sheet view. Forms are also a very efficient way of entering data into your tables. Overall a form is an excellent layout for entering, viewing, or changing the data in your database. The information for a form can come from a table, a query, or both.
Since you want to get done with this lab quickly and since I don't want you mess with my Joni database I will not bore you with details about forms.