Assignment 5 - Advanced SQL

Due: 3 May, 2010

Instructions:

  1. - SSH to the ecom2 server (ecom2.wiu.edu)


  2. - At the unix prompt, run this command:
    cp /home/mfjlw1/assign5_load.txt ~/assign5_load.txt


  3. - At the unix prompt, run this command:
    touch assign5_load.log (this is to create an empty log file...)


  4. - To create your new database, at the unix prompt, run this command:
    mysql -vvv -u root -p < assign5_load.txt >> assign5_load.log (NOTE: you will be prompted for you password. Enter it and press enter)


  5. - To view the results of running the commands to load your database, at the unix prompt, run this command:
    cat assign5_load.log | more

  6. Check the results for errors.

These commands will create the product, assembly, department, and employee tables and populate them with data.

Data model for the above tables

 
Create the SQL to answer these questions:

1. List the product id, description and price for products that are composed of other products. Remove duplicate rows. 

2. List the product id, description, quantity, product price, and extended price (price * quantity) of all products that compose the product with product id of 2000. 

3. List the product id, product description, price, and the total cost to the company for producing the product with product id of 2000? 

4. List any product that is neither used in or is composed of other products. 

5. List the department name, floor, phone, total salaries of employees that work in it, and average salaries of employees that work in it for all departments. 

6. List name (first and last) of any employee, and the name (first and last) of the boss where an employee has a higher salary than their boss. Also list the difference in salary. 

What to turn in: A print out of the SQL for each query, with the results of running that query.


Home | Syllabus | Assignments
Schedule | Hand Outs | Lesson Outlines
College of Business and Technology | Information Management & Decision Sciences
Western Illinois University | Western Illinois University Regional Center