Question

In: Advanced Math

For this assignment, you will use the provided database in the Unit 5 script file. You...

For this assignment, you will use the provided database in the Unit 5 script file. You will add statements to this file to query the database tables. For your reference, below is a screenshot of the enhanced entity relationship diagram (ERD) as a reference when you write your queries. With the data types listed in the diagram, this will help you identify the types of operators that you can use for particular queries.

Use paiza.io for MySQL to execute and troubleshoot your Structured Query Language (SQL) statements. It is recommended that you use Notepad to write your SQL statements. Then, copy and paste your SQL statements to paiza.io to test your statements to ensure that they execute without errors. Save your work frequently.

The asterisk (*) indicates that a column is not null (i.e., required to have a value).

  1. If you would like to see the test SQL statements, click on “Run” to see the statements execute. You should see “Hello” appear in the Output window (see the following screenshot).
  2. Because you do not require these test SQL statements for your assignment, delete the sample SQL statements. To do this, select the text, and click on the Delete key on your keyboard. Your MySQL paiza.io screen should now be blank, as you see in the following screenshot. Note that if you ran the test statements, “Hello” will still appear in the Output window.
  3. Copy and paste the code from the provided script file into the code editor, and click on “Run” (“Ctrl + Enter”). You should see no error messages displayed in the Output area at the bottom of your paiza.io screen. After you click on “Run,” you should see a green bar with “Success” at the top. You will see this circled in the following screenshot:
  4. Next, you will write 1 query to respond to each of the following questions. Note that you can only use the information that is in the question or the enhanced ERD. Write a query to do the following:
    1. Display all of the rows in the publisher table.
    2. Display all of the books in the book table that were written by the author whose author ID is 1504192.
    3. Display all of the purchases in the shopbasket that were ordered on 2020-02-29.
    4. Display the largest quantity ordered in the shopbasket.
    5. Display the authors' first and last names sorted by their last name.
    6. Display a count of the number of orders placed via the shopbasket.
    7. Display the order date and quantity of orders in the shopbasket that have a quantity of more than 25.
    8. Display the first and last names of those authors who have a null Facebook.
    9. Display all of the customers' names, city, and state if they live in GA, FL, or CA.
    10. Display the book titles of those books that were not published by Scholastic Press.
    11. Display the first and last names of the authors and the book titles. Only display those authors who wrote a book with the word database in the title.
    12. Add a multiline comment before the first CREATE TABLE statement that includes your name, the course code (ITCO231), and the date when you are submitting your assignment.
  5. Save your script file using your last name, ITCO231, U5, and the file extension .sql, as in “Smith_ITCO231_U5.sql.”
    1. Tip: When saving a Notepad file, you can change the file extension to .sql as required for the assignment by changing the “Save as type” to “All Files” and then typing the .sql extension, as shown in the example.

I didnt understand by what you mean by SQL TEST. If what you are asking me is that an SQL TEST? Yes! It is SQL QUERY TEST!!

Solutions

Expert Solution

a) Display All of the rows in the Publisher Table

SELECT * FROM publisher

b) Display all of the books in the book table that were written by author 1504192

SELECT * FROM book WHERE author_id = 1504192

c) Display all of the purchases in shopbasket that were ordered on 2020-02-29

SELECT * FROM shopbasket WHERE order_date = '2020-02-29'

d) Display Largest Quantity in ShopBasket. Here we will use the MAX aggregation Function.

SELECT MAX(quantity) FROM shopbasket

e) Display author First and Last name, sorted by last name

SELECT first_name, last_name FROM author order by last_name

f) Display number of orders placed via shopbasket. Here we will use the Count Aggregation Function to get the total rows.

SELECT count(1) from shopbasket

g) Display order date and quantity of orders in shoporders where quantity more than 25

SELECT order_date, quantity FROM shopbasket where quantity > 25

h) Display First and last Names of Author who have null facebook

SELECT first_name, last_name FROM auhtor where facebook IS NULL

i) Display Customers Name, City and State if they live in GA,FL or CA

SELECT first_name,last_name, city,state FROM customer where state in ('GA','FL','CA')

j) Display book titles of those books that were not published by Scholastic Press

SELECT b.title FROM book b JOIN publisher p ON b.author_id = p.author_id where p.name <> 'Scholastic Press'

k) Display the first and last names of the authors and the book titles. Only display those authors who wrote a book with the word database in title. Here wie will use the Wild card operator "LIKE"

SELECT a.first_name, b.last_name, b.title FROM author a JOIN book b ON a.id=b.author_id WHERE b.title LIKE '%database%'

HOPE YOU LIKE IT AND PLEASE GIVE UPVOTE.

IF YOU HAVE ANY DOUBT, LET ME KNOW IT IN THE COMMENT SECTION. I WILL REPLY ASAP.

HAVE A NICE DAY.

THANK YOU.


Related Solutions

Assignment Description: In this assignment, a script file should be created to contain a set a...
Assignment Description: In this assignment, a script file should be created to contain a set a SQL statements for the Pretty Prints Company to better manage their business. Use the database created for Pretty Prints in Assignment 2. Include the SQL statements to satisfy the following queries. The following queries should be included in the script: Create a view named Under_100. It consists of the item_id, title, artist, unit_price and order_qty for every print with a unit_price under 100 dollars....
in this assignment you will create and use a database to find meanings and synonyms for...
in this assignment you will create and use a database to find meanings and synonyms for given phrases. To do so you will use tables of synsets -- sets of one or more synonyms (specific phrases) that share the same meaning. Your program should: Display a message stating its goal Create a database file using SQLite using your name (i.e. use your name as a file name - for example, my database will be named "nimdvir") In your database, create...
Use Vi text editor or ATOM to create a bash script file. Use the file name...
Use Vi text editor or ATOM to create a bash script file. Use the file name ayaan.sh. The script when ran it will execute the following commands all at once as script. Test your script file make sure it works. Here is the list of actions the script will do: It will create the following directory structure data2/new2/mondaynews off your home directory. inside the mondaynews, create 4 files sports.txt, baseball.txt, file1.txt and file2.txt. Make sure file1.txt and file2.txt are hidden...
In this assignment you will write a program that encrypts a text file.  You will use the...
In this assignment you will write a program that encrypts a text file.  You will use the following encryption scheme. Ask the user for the name of the original file. Ask the user for the name of the output file. Ask the user for the encryption key, n. Read n2 characters from the file into the n rows and n columns of a 2-dimensional array. Transpose the array.  (Exchange the rows and columns.) Write the characters from the array to an output...
For this assignment, you will read the scenario and then use the provided Excel and Word...
For this assignment, you will read the scenario and then use the provided Excel and Word document templates to complete your assignment before uploading them to the assignment submission area. Scenario Larry and Beth are both married, working adults. They both plan for retirement and consider the $6,000 annual contribution a must. First, consider Beth's savings. She began working at age 20 and began making an annual contribution to her IRA of $6,000 each year until age 32 (12 contributions)....
Write a program that reads a file (provided as attachment to this assignment) and write the...
Write a program that reads a file (provided as attachment to this assignment) and write the file to a different file with line numbers inserted at the beginning of each line. Such as Example File Input: This is a test Example File Output 1. This is a test. (Please comment and document your code and take your time no rush).
We have provided you the Hotel database to be used with SQLite DBMS. You should use...
We have provided you the Hotel database to be used with SQLite DBMS. You should use this database in SQLite to extract the necessary information as per the following query requirements. The sqlite script is based on the following relational schema: •Hotel (hotelNo, hotelName, city) • Room (roomNo, hotelNo, type, price) • Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) •Guest (guestNo, guestName, guestAddress) Note the following details of the hotel database; •Hotel contains hotel details and hotelNo is the primary key;...
In order to submit this assignment, you will use this webform to upload a document file...
In order to submit this assignment, you will use this webform to upload a document file (.doc) or (.docx) with your answers. If you need to make a graph you may use a drawing program or sketch by hand. Report your source in APA or MLA format. Be sure that your responses model clear economic reasoning and addresses each of the following: What are the advantages and disadvantages of a fixed exchange rate? What are the advantages and disadvantages of...
In order to submit this assignment, you will use this webform to upload a document file...
In order to submit this assignment, you will use this webform to upload a document file (.doc) or (.docx) with your answers. If you need to make a graph you may use a drawing program or sketch by hand. Report your source in APA or MLA format. Be sure that your responses model clear economic reasoning and addresses each of the following: What is the effect of expansionary fiscal policy on unemployment and inflation? Go online and find an article...
In order to submit this assignment, you will use this webform to upload a document file...
In order to submit this assignment, you will use this webform to upload a document file (.doc) or (.docx) with your answers. You may use a drawing program or sketch by hand. Be sure that your responses model clear economic reasoning and addresses each of the following: 1.) Suppose if the price of a good is $12, the quantity demanded is 50 units; when the price is $10, the quantity demanded is 100 units. Use the midpoint approach to compute...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT