CS317, Files and Systems:

Exercise #1 – Familiarity with MySQL Database Systems

DUE: As Indicated on Canvas and Syllabus

Please thoroughly read DBMS, Chapter 1 & 2, thoroughly. Also, please complete the MySQL tutorial using your account on PRClab1 (or your own installation if you prefer on VB-Linux) explore Oracle MySQL Example including: Sakila [docs], World [docs], Menagerie and Employee Data [docs]. While working on this lab, you may find it useful to refer to the MySQL Reference Manual.

Learning objectives:

1) Accessing an R-DBMS via command line and phpMyAdmin for data manipulation, 2) Basic understanding of DBA grants and privileges and getting DBA help, 3) Exploring an existing DB schema (tables) and tuples (rows) and attributes (columns), 4) Forming DML queries using MySQL documentation and your book to answer questions about data in a database.

Exercise #1 Requirements:

1) [25 points] Please refer to the MySQL tutorial and reference manuals as noted while working on this assignment as needed (i.e. you are expected to look up commands needed). a) [5 pts] Simply log into PRClab1 and MySQL, change your password, and then do “show databases;” - provide a screen dump in your report to show that you’ve done this. If you have any issues with PRClab1 access or MySQL access, please resolve this expeditiously (for PRClab1 access issues, submit and IT ticket to [email protected] and for any issues with MySQL access on PRClab1, send an e-mail to our TA/DBA and copy me – [email protected] and we will help you resolve). b) [5 pts] Use the command “show grants;” and explain why your instructor has set up your privileges the way you see them – provide show grants output in a screen shot and provide a detailed explanation of the output. Do you see any potential security issues with your privileges? c) [15 pts] Explore the sakila DB using both the command line and phpMyAdmin. You can connect to Adminer or PhpMyAdmin and login as you do at a prompt as another method to explore the database compared to command line. Now, answer the following questions and provide screen dumps to demonstrate how you came up with your answers: i) How many tables are in the DB and what are they? ii) How many films are in the DB? iii) Try the command “describe film;” – what would you use it for? iv) What are the columns in the table “actor”? v) Use select query to list all actors in the database in alpha order by last-name and default order – how many are there? How many have the last name WOOD.

2) [35 points] For this next exercise, use your database which is named usernamedb – e.g. siewertsdb for which you should have all privileges granted. Verify that you do with “show grants;” command. a) [10 pts] Follow the MySQL tutorial for “Creating and Using a Database” starting with Creating a Table and when you’re done, do “show tables” and “select * from yourtable” to demonstrate. b) [25 pts] Add a table to your database called myhomes that includes fictitious addresses for 8 homes that you would love to have any place in the world. The table should include columns for address number, street, city, and zipcode along with number of bedrooms and bathrooms. When you are done populating this new table with 8 new homes, do “select * from myhomes” to show what you have populated your table with. Leave you database as you finish so we can examine what you’ve done as DBA.

3) [40 points] Using the sakila database, create queries to do the following: a) Find all films that are have ever been rented. How many are there? b) How many films are rented out and have not been returned? c) How many films are overdue? d) Create a list of currently rented films (limit to 5 sorted by customer_id) and provide a screen dump of your query and results. e) Create a list of overdue DVDs (as described here - http://dev.mysql.com/doc/sakila/en/sakila-usage.html ) and explain to the best of your knowledge what the INNER JOIN operation does.

Overall, provide a well-documented professional report of your findings, output, and tests so that it is easy for a colleague (or instructor) to understand what you’ve done, what worked, what did not and why (even if you can’t complete to your satisfaction). Include any SQL source code and commands you write (or modify). I will look at your report first, so it must be well written and clearly address each problem providing clear and concise responses to receive credit, but I will look at your SQL (record each successful command you issue if interactive) as well if I have questions.

In this class, you’ll be expected to consult the Oracle MySQL reference manual and tutorial pages and to do some reading and research on your own, so practice this in this first lab and try to answer as many of your own questions as possible, but do come to office hours and ask for help if you get stuck.

Upload all SQL you develop and your report completed using MS Word or as a PDF to Blackboard and include any supporting information you want in appendices (ideally example output should be integrated into the report directly, but if not, clearly label in the report and by filename if test and example output is not pasted directly into the report). Your report must include SQL so I can repeat your queries and replicate your results. Please zip your solution with your last name embedded in the file name.

Grading Rubric

[25 points] MySQL basic exploration:

[5 pts] a) ______

[5 pts] b) ______

[15 pts] c) ______

[3] i)

[3] ii)

[3] iii)

[3] iv)

[3] v)

[35 points] Work with custom database:

[10 pts] a)______

[25 pts] b) ______

[45 points] Advanced queries with example DB______

[8 pts] a)______

[8 pts] b) ______

[8 pts] c)______

[8 pts] d) ______

[8 pts] e)______