Lab/Program Assignment 1
Version 1.0 - initial release
Due: 11:59PM on Sunday, Feb 4th
Late Period: 11:59PM on Tuesday, Feb 6st
Lab Assignment 1a: Finding your way around in SQL
- The purpose of this assignment is twofold:
- To introduce you to using MySQL on faure;
- To help you become familiar with some common SQL commands;
- To introduce you to using MySQL on faure;
Overview of Task
For this project you will learn how to access our department MySQL server(faure) and work with a sample database provided below. The database implements a simple employees file and consists of several simple tables for organizing departments, managers, and employees. A copy of the schema for this database can be found here.
- Log into one of the department machines, either by working in one of the CS labs, or by ssh from home.
- run mysql by executing the following command:
mysql -h faure.cs.colostate.edu -p
- This should drop you into mysql and request a password.
- Once you have entered the password (initially your CSU id), you can begin to nose around.
- Remember that if you are using faure, you do not have permissions to create a database. Instead, one by the same name as your user id has been made available for you to use.
- Common mysql commands.
Before you start your operation on mysql database, it's good to know the following mysql commands.
Refer to the tutorial in the documentation for more detailed information.
Don't forget to terminate every command with a semicolon,
otherwise you will get the mysql command continuation prompt:
If this happens and you're done entering your command, simply enter
a ";" and the command will
- show databases; This command shows all of the databases that your mysql server is managing. If you are running on faure, this will show your personal database available there. Database in this sense refers to a collection of tables (relations) for supporting a complete conceptual model of the world.
- use <database>; This command changes the current database to <database>. For security reasons, on faure we do not allow databases to be created, so you must use the database of your own name here.
- show tables; This command shows all of the tables (relations) for the current database (refer to the use command for changing the current database).
- describe <table>; This command describes the field names, types, and values for the table named <table>.
- select * from <table>; This command shows all of the data within the table named <table>.
- OK, now lets get to the assignment.
- Use the tee command to put your output in a text file to submit, Be sure to use a .txt extension, otherwise it won't be graded.
- Use ? at the MariaDB prompt for help
- type in use [your database's name]; [your database's name] should be your existing database whose name is your cs department login name. Caps aren't important but spelling is. Type in show tables;" and you should see nothing.
- Create the employees tables in the new database. First think about what kind of information you would need to create a employee database. Would you put all of it in a single table or separate it into multiple tables? A script file is provided that you can run with mysql in batch mode to create the necessary database Run it by using the source command from within mysql. HINT: source file_name.sql in mysql prompt.
- Examine the tables. Use the "describe" command to look at the structure of each table. Use the documentation to help understand data types, syntax, etc. Yes, you are being thrown into the deep end and having to swim, so start paddling.
- Load the database with some data, specifically the data provided in
this script file.
Execute it the same way as you did in creating the tables.
Below are the data files that must be local to your account. A tar file can be found here if that is easier for you.
- Run some queries against the database. Here is a script file that contains some sample queries. Examine the output to see if it makes sense.
- What is the difference between the first and second query? Why?
- What is the difference between the second and third query? Why?
- Type in notee to stop the tee command.
Part1: Bringing up mysql on faure
Part 2: Create and/or use a provided database. You need to find a way to solve Question 4, 6, 7, and 8.
- Upload the output file generated while you were executing the assigment.
- All text files MUST have a .txt extension (Canvas cannot handle them otherwise.
- Answer the 2 questions from #8 above in a .pdf document.
Note: These must be done in the same submission. The TA will only grade the latest submission, if they are not together you will lose points
- Submit the assignment.
- Assignments turned in during the late period are subject to a 20% late penalty.
- In addition, refer to http://dev.mysql.com/doc/mysql/en/ for the online MySQL Reference Manual, as well as information on downloading MySQL onto your own machine.
Submitting Your Assignment
Using the Canvas CS 430 Assignment Submission portal
This is Lab Assignment 1a.
For more information on SQL