QUERY AND UPDATE DATABASES USING SQL

Qualified Writers
Rated 4.9/5 based on 2480 reviews

100% Plagiarism Free & Custom Written - Tailored to Your Instructions

Task

 

NOTES

 

  • In this assignment you have a choice to use either MySQL or SQLite.
  • If you are using SQLite, follow the instructions listed below:
  • For guidance on how to install SQLite, watch this short YouTube video: https://www.youtube.com/watch?v=YZQuQ6jael8
  • For guidance on how to create tables using SQLite, watch this short YouTube video: https://www.youtube.com/watch?v=Ev2JnjavvmE
  • If you are using MySQL: The instructions for using MySQL will be placed in the Students Resources Folder.
  • To use other packages, please seek the approval of your subject coordinator.
  • Typing the SQL statements or the results is NOT acceptable.

 

If you are using SQLite, please note the guidelines given below:

 

·         Copy sqlite3.exe and cmd.exe files from the Students Resources Folder into a folder in your machine

·         Copy a5.txt from the Students Resources Folder into the folder in your machine where your SQLite file is located

·         Open a5.txt in Notepad

·         Replace yourstudentid in line .output yourstudentid.txt in a5.txt with your actual studentid i.e. for example 45446667.txt

·         From the Command Prompt type sqlite3.exe yourstudentid.db

·         Note: From the Command Prompt call the folder in your machine where your SQLite file is located before you type sqlite3.exe yourstudentid.db

·         At the SQLite Command Line type .read a5.txt [to create the tables you will use to answer this assignment’s questions]

·         At the SQLite Command Line type .quit

·         Using WordPad open yourstudentid.txt [to check the tables you created exist]

·         From the Command Prompt type sqlite3

·         At the SQLite Command Line type .open yourstudentid.db

·         At the SQLite Command Line type .headers on

·         At the SQLite Command Line type .mode column

 

Instructions for using MySQL Workbench

 

From Resources under Main Menu in Interact 2 go to Students Resources Folder

 

Download ‘assignment5’ to your student folder.

 

If you are using MySQL, you need to import the database file called ‘assignment5’ before you can commence your work on this assignment – after importing you should see ‘assignment5’ showing in the left hand side list on MySQL Workbench. You are now able to start your assignment5 tasks as listed below:

 

Assignment 5 tasks: each query is worth 5 marks

 

Write and run SQL statements to complete the following:

 

Part A - DML

 

  1. List the record/s in the vendor table that do not have a value for the attribute V_STATE.
  2. Find the customers whose balance is greater than $250 but less than $400.
  3. Create a query based on invoice table to show a 15% increase on tax.
  4. Show the names of the customers for whom we have generated any invoices.
  5. Show the CUS_CODE of the customers for whom we DID NOT generate invoices.
  6. Show the names of the customers for whom we DID NOT generate invoices.
  7. Find out how many times a customer generated an invoice – make sure the counted column heading reads “Invoices_generated”.
  8. List the names of the customers and how many times a customer generated an invoice – make sure the counted column heading reads “N_Of_Invoices” .
  9. Find the customers whose last name is either Dunne, Orlando or Brown and live in area 615, sort in alphabetical order by the CUS_LNAME.

 

Part B – DDL

 

  1. Add a new attribute called ‘email_address’ to ‘emp’ table with data type and length ‘VARCHAR-20’.
  2. Add a new row/record to the `customer` table to include your actual student ID in the CUS_CODE, your lastname as the CUS_LNAME` and your firstname as CUS_FNAME. Add any other details of your choice in all the other fields.
  3. Delete all the vendors in the FL state.

 

You are required to submit:

 

  1. The SQL statements for each query, which should be copied from your SQLite3 Command Line and pasted into your submission file
  2. The screenshots of the results of the SQL statements which are to be copied from your MySQL Workbench screen or SQLite3 Command Line and pasted into your submission file immediately after you execute the SQL query.

 

Rationale

 

This assignment will assess your knowledge and ability to use SQL to query database tables and update them. It will also test your ability to write both simple and complex queries and run those queries to return the requested data.

 

Marking Criteria

 

Task

HD

DI

CR

PS

Write and run SQL statements to complete tasks 1-12 above

The SQL statements retrieve or update the required information for all assignment tasks using concise, correct and free of errors SQL syntax that

The SQL statements retrieve or update the required information for most of the assignment tasks using correct and free of errors SQL syntax

The SQL statements retrieve or update the required information for some of the assignment tasks using mostly correct SQL syntax

The SQL statements retrieve or update the required information for only a few of the assignment tasks using SQL syntax that contains frequent errors

 

Price: £109

100% Plagiarism Free & Custom Written - Tailored to Your Instructions