SOLVED: IST 634 Assignment 1  MySQL Administration and Simple Queries

 

Introduction - In this laboratory exercise you will gain initial experience with MySQL Server and the MySQL Workbench application.

Instructions – Create a Microsoft Word document. For each task, paste a screenshot (more than one if necessary) into a single Word document proving that you have carried out the task. Submit the document via Blackboard. Due date: 10/1/2020 7:00am.

Download/install MySQL Server and Workbench if you have not already done so. Start the server, open MySQL Workbench and create a connection for the root account. Connect to the server using this connection. The COMPANY database of the Elmasri/Navathe text (see Figure 5.5, e.g.) will be used throughout this assignment (and possibly more assignments). Carry out each of the following tasks from SQL Workbench.

1. From your MySQL Administrator (root account), create the company database (it will be empty – you will create the components of the schema, tables, later).

2. Create a user book and grant all rights on company to the user book (book is not an administrator, so should have no other rights). This can be done using SQL commands of the following form:

CREATE USER my_user;

GRANT ALL PRIVILEGES

ON my_database.*

TO my_user

WITH GRANT OPTION; 

A command can be all on one line, but having on multiple lines makes it easier to read. The ‘;’ terminates a single SQL command.

Create a MySQL Workbench connection for the book account. Use this connection to connect to the server. Choose the company database (if not part of your connection).

4. For each table in the company schema (see Figure 5.5), create a DDL statement to add the table to the database, then execute the statement. You may want to create a SQL script (file with extension .sql) for each statement to make it easier to create/modify the DDL statement. An example of such a statement is given in the file ‘employee.sql’ which is part of this assignment (you will need to take out the foreign keys from the tables – you should put them back in with ‘ALTER TABLE’ commands after you have loaded the table with data).

5. After you have created the tables in the company database, you need to fill them with data. Each table X has a file X.dat with data for that table attached to this assignment (these are text files, so have a look at them with your text editor). You will use the MySQL LOAD command to accomplish this. An example SQL script for loading the data into the employee table is attached to this assignment. Execute this script, and then a SQL ‘select *’ query to be sure that the data has been loaded. Create and execute scripts for the remaining tables, executing ‘select *’ to prove that the data has been loaded. (You may need to ‘clean up’ the data in some of the .dat files in order for it to load, you will get an error message when you try to execute the LOAD statement if this is the case – try to load and note where any errors occur – start the cleanup from there and try to load again).

IMPORTANT NOTE – THERE IS SOME DIFFICULTY USING LOAD WITH THE NEW VERSION OF MYSQL, SO FOLLOW THESE STEPS BEFORE DOING THE LOADS!

On MacOS:

1. Create a my.cnf file with the following statements:

[client]

port            = 3306

[mysqld]

port            = 3306

secure_file_priv=''

local-infile = 1

2. Set the my.cnf file as the default configuration file

3. Restart the MySQL server

4. Try the following statements in MySQL Workbench:

SHOW VARIABLES LIKE "local_infile";  //Should be ON

SHOW VARIABLES LIKE "secure_file_priv";  //Should have no values (not NULL but blank)

5. Put the files you want to upload in the /tmp folder

6. LOAD DATA without the LOCAL keyword (i.e., LOAD DATA INFILE 'your_file' INTO TABLE table_name ...)

On Windows:

1. Run the following statement in MySQL Workbench:

SET GLOBAL local_infile = 'ON';

2. Run the following statement and make sure it shows ON:

SHOW VARIABLES LIKE "local_infile";

3. SHOW VARIABLES LIKE "secure_file_priv"; //Then you'll get the default path, usually C:ProgramDataMySQLMySQL Server 8.0Uploads

4. Put your files into the folder shown in step 3

5. LOAD DATA without the LOCAL keyword (i.e., LOAD DATA INFILE 'your_file' INTO TABLE table_name ...)

6. Create a query to retrieve the names of all employees in department 5 who work more than 10 hours per week on the ProductX project. Execute the query and show the results.

7. Create a query to list the names of all employees who have a dependent with the same first name as themselves. Execute the query and show the results.

8. Create a query to find the names of all employees who are directly supervised by ‘Franklin Wong’. Execute the query and show the results.

9. Create a query to change the location of department 8 from Chicago to Cleveland. Execute the query and show the results.

10. Create a query to add a new daughter born today named Sarah for Franklin Wong (make up a SSN for Sarah which is unique). Execute the query and show the results.

11. Create a query to delete the Computerization project. Execute the query and show the results.

 

Disclaimer

The assignment sample provided by Assignments Consultancy is a previously completed work for another student and contains plagiarism. It is being shared only as a reference or guideline to help you understand how to structure and approach your own assignment. We do not recommend submitting it directly as your own work. You are solely responsible for ensuring the originality and integrity of the assignment you submit, and we advise using this sample only as inspiration while adhering to your institution's academic policies.

LEAVE A COMMENT

Comment Box is loading comments...