Query and update databases using SQL

Query and update databases using SQL

Assessment item 5

Query and update databases using SQL

Value: 15%

Due date: 08-Oct-2015

Return date: 30-Oct-2015

Submission method options

Alternative submission method

Task

NOTES

  • This assignment encourages you to use SQLite to complete the tasks listed below.
  • The instructions listed below relate to SQLite.
  • 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
  • You are welcome to use 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.

Instructions

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

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

 

Write and run SQL statements to complete the following tasks

 

  1. Show all the details of the products by v_code 21344
  2. Locate the record in the vendor table that does not have a value for the attribute V_STATE
  3. Find the customers whose balance is greater than 200 but less than 300.
  4. What is the max balance?
  5. Show the names of the customers for whom we have invoices.
  6. Show the CUS_CODE of the customers for whom we DO NOT have invoices.
  7. Show the names of the customers for whom we DO NOT have invoices.
  8. Find out how many times a customer generated an invoice.
  9. List the names of the customers and how many times a customer generated an invoice.
  10. Add a new attribute (field) credithistory varchar(6) to the customer table.
  11. Update credithistory for customer ‘10011’ to ‘Bad’.
  12. Delete the employee Leighla Genkazi from the EMP table.

 

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 SQLite3 Command Line and pasted into your submission file immediately after you execute the SQL query. If you used an output file please submit only the output file

 

 

 

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

The following criteria will be used to assess Assignment 5:

 

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 theassignment tasks using correct and free of errors SQL syntax

 

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

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

 

 

"Order a similar paper and get 15% discount on your first order with us
Use the following coupon
"FIRST15"

Order Now