UC Berkeley School of Information

IS 257: Database Management


Most of the assignments in this course will be related to your own database and exercises to familiarize you with the systems that we will be using. A second set of assignments will involve the use of an existing database to answer a set of queries, or to modify the database. The same database (called "Diveshop") will be used for the second set of assignments. We will discuss these assignments further in class.

Although there are no formal laboratory sessions scheduled for this course, it should be obvious that you will need to spend a lot of time on your computer to accomplish the assignments.

Assignment 1 (Individual)

Due Feb 27th

Using your own copy of the Diveshop MySQL database, create queries that produce the answers to the following questions (DiveShop Queries, below). The results should contain only the answers requested -- plus evidence to support them -- and no more (see below).

The Diveshop database for MySQL can be downloaded HERE.

See the MySQL Tutorial - including phpMyAdmin created by Kevin Heard, if you have any trouble with the assignment. This tutorial shows (among other things) how to load the Diveshop database into your MySQL account so that you can use it for this assignment. See also clarifications below.
For MySQL the phpMyAdmin program can be used to access your database (Note that the database must have been previously set up for you and you have both an iSchool account and database name and password sent to you by Kevin)

For more information on SQL consult Chapter 6 (particularly the section on the SELECT command) in the Hoffer textbook. Also, the MySQL reference manual is available online at this site.

As a reminder, the basic form of the SQL Select command is:

 SELECT attrname1[, attrname2,... attrnameN] 
 FROM table1[, table2,... tableM]
 [WHERE table1.attrnameX = 'value' 
       [AND table2.attrnameY = table1.attrnameY AND ...]]
 [ORDER BY tableM.attrname1 ASC, ... DESC] ;

The brackets indicate optional parts that may not be needed depending on the query.

To do the queries you will need to become familiar with the structure of the DiveShop database and how individual relations are linked. The ER diagram linked below should should help with this. To link relations (tables) in an SQL SELECT command you simply need to have statement like "table2.attrnameY = table1.attrnameY" where attrnameY is the name of the common attribute that links the relations (such as "Destination_No" linking the DEST and SITES tables could be specified as "DEST.Destination_No = SITES.Destination_No").

We will also be reviewing how to use phpMyAdmin and do SQL queries in class.

DiveShop Queries

  1. How many tons was the sunken ship Delaware?
  2. What is customer Karen Ng's address?
  3. At what destination and site(s) might you find a Spotted Eagle Ray?
  4. Where (what destination) is the site Palancar Reef?
  5. What sites might Lorraine Vega dive on her trip?
  6. Keith Lucas wants to see a shipwreck on his trip. Is he going to the right place?
  7. What equipment is Richard Denning getting?
  8. What is the cost of the equipment rental for Louis Jazdzewski.

ER diagram of the DiveShop Database

  1. The Database is available from the course web site (click here to download it)
  2. Download your own copy
  3. For each of the questions create a query in phpMyAdmin.
  4. Create a document (Word, etc.) containing
  5. The query being answered
  6. The results of your query cut and pasted from phpMyAdmin
  7. TBD on submission method: I will get back to you on this

A couple of clarifications:

  1. For the last question, we are asking you how much Louis Jazdzewski is PAYING for the stuff he is renting. (Keep in mind that Louis might be renting more than one of some of the items and we are interested in the total amount he is paying.) We are not asking you what was the "cost" of those items to DiveShop or what the sale price of those items would have been if they were sold rather than rented. Note that the last two numbers would naturally be higher than the rental price.

  2. If you ever get more than a full page of results for your query, you are probably doing something wrong. Most likely you are searching two disconnected tables. All the tables that are a part of your query must be connected. See the ER diagram to see how the tables are linked.

  3. You may get zero results in response to some your queries since some combinations just don't exist. This may mean that the answer the question really is "none/nobody/nowhere" etc. Or it may mean that you misspelled a name or set a wrong constraint.

Assignment 2a (Group)

Due Friday February 26th

Database Project Group Formation

You must form into groups of 3 - 5 for the Database Project

Form groups of 3 - 5 for your project. These groups will be for Assignment 2 and 4 as well as the Final Project. There are no exceptions. If you are not in a group you will be assigned to a group.

Assignment 2b (Group)

Due Friday March 16th

Database Project Design (2-4 pages)

The following information should be decided and turned in for the preliminary design of your personal database project.

These will be preliminary design specifications, so do not feel that you must follow everything that you describe here in the final database design.

Here are some project ideas from previous years:

Assignment 3 (Individual): MySQL Command line Diveshop Queries

Due Tuesday Apr 3

MySQL Setup

Connecting to MySQL on Harbinger (or follow the instructions in the tutorial by Kevin Heard on the web site).

Making queries with mysql

At the unix command prompt enter "mysql -p yourMySQLusername" to start interacting with MySQL:

  harbinger:~ --> mysql -p ray
  Enter password:

  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A

  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 788010
  Server version: 5.0.45 Source distribution

  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


At the "mysql>" prompt you can start entering SQL commands.

Enter "edit" at the mysql> prompt to go into your default editor (PICO is the default). When you save and exit from the editor, the edited query will be returned in the mysql buffer. Alternatively, you can save your queries in a file on your desktop/laptop and copy and paste them back and forth between the file and the ssh prompt.

Be sure to end each SQL command with a semicolon.

To see what diveshop tables are available, submit the command:

show tables;

To see the fields for a particular table issue the command

describe tablename;

where "tablename" is replaced with the name of the table you are interested in.

You are also welcome to use the interactive phpMyAdmin to do this (or any of the the other steps), as described in Kevin Heard's tutorial.

Capturing Output

When you run a query, you are likely to see rather messy output, e.g.:

mysql> select * from SITES;

| site_No | Destination_No | Site_Name           | Site_Highlight | Site_Notes | Distance_from_Town_m | Distance_from_Town_km | Depth_ft | Depth_m | Visibility_ft | Visibility_m | Current | Skill_Level  |
|    1001 |              1 | Palancar Reef       | Reef           | NULL       |                   10 |              16.09344 |      100 |   30.48 |           150 |        45.72 | Strong  | Intermediate |
|    1002 |              1 | Santa Rosa Reef     | Reef           | NULL       |                    8 |             12.874752 |       80 |  24.384 |           150 |        45.72 | Strong  | Intermediate |
|    1003 |              1 | Chancanab Reef      | Reef           | NULL       |                    4 |              6.437376 |       60 |  18.288 |       
 ...many lines skipped...

About the only way to capture the results and make them pretty is to use the "tee" command to put the output into an external file and then use an editor to modify it.

 Logging to file 'MYSQLOUTPUT'
 -> select * from SITES;

 ... lots of lines like above ...

 mysql> \t
 Outfile disabled.
 mysql> \q    

 harbinger:~ --> more MYSQLOUTPUT

 mysql> select * from SITES;
 ... etc. ...

This MYSQLOUTPUT file can be edited in any editor you prefer (it is just a text file)

New Diveshop Questions

  1. What are the names and addresses of the diveshop customers who are renting masks?

  2. What are the names of the wildlife that Mary Rioux might see on her trip. Are there any Shipwrecks there (give names)?

  3. What sunken ships might be candidates for treasure hunters whose destination is New Jersey?

  4. Who is paying the maximum amount for single type of rental equipment (use price * quantity to determine amount)?

  5. At how many sites might you see a "Nassau Grouper"?

  6. What are the names of customers who are paying in cash?

  7. Produce a list of all equipment being rented for a dive vacation that costs more than $30000, make the list in descending order of the rental price of the equipment.

  8. Who is renting teal colored equipment? (see DIVESTOK.Description)

  9. Which locations have an avg temperature of more than 75 degrees Farenheit and a travel cost of under $4000?

  10. Make up two queries of your own and run them turn in the queries and the results.

NOTE: Examine the questions carefully - if it asks for something that is rented be sure to verify that an item is a rental and not a sale or you will have wrong answers

You can also create an SQL command file that contains multiple SQL and mysql commands. The command file contents might look like the following:

\T myoutputfile

select Ship_Name, Tonnage from 
       SHIPWRCK where Ship_Name like 'Delaware'



The "\p" command prints the current command in full (so it can be captured to the "myoutputfile" file along with the query results). The "\g" command runs the query (like a semicolon).

A command file like the one above can be created in a text editor (be sure to save as a plain text file). To run a command file like this one, which already includes the commands to capture the results for further editing or printing, issue the commands:

mysql> \. commandfilename

Where "commandfilename" is the name you saved the command file as.

Turn in the edited version of your commands to answer the questions above from the Diveshop database, including the SQL commands used to obtain your results.

Assignment 4 (Group)

Due Friday May 4th

There are three deliverables for this assignment:

The written report

Because this is a continuation and expanded version of Assignment 2, you should be sure to remedy any problems pointed out in that assignment, and also describe any design changes made since then. The instructions below include description of what is wanted depending on whether you will be using Access, MySQL or some other database system for your project. You only need to use one database system and provide the information appropriate for that system. The report should include the following information:

The final presentation

Every group is required to give a 10 minute presentation on their project. The presentation should include the following:

The web application implementing your database

Every group should have a working implementation of their database and should at minimum include the following:

If your looking to go above and beyond (we reserve judgment to give extra points) include the following pages

Overall we will be grading on the following criteria:

The dimensions (each is worth 1/4 of the grade):