Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppliers (SupperID, CompanyName, ContactLastName, ContactFirstName, Phone) Books (BookID, Title, Unit_Price, Author, Unit_in_Stock, SupplierID, SubjectsID) Subjects (SubjectID, CategoryName) OrderDetails (BookID, OrderID, Quantity) Customers (CustomerID, LastName, FirstName,

Suppliers (SupperID, CompanyName, ContactLastName, ContactFirstName, Phone) Books (BookID, Title, Unit_Price, Author, Unit_in_Stock, SupplierID, SubjectsID) Subjects (SubjectID, CategoryName) OrderDetails (BookID, OrderID, Quantity) Customers (CustomerID, LastName, FirstName, Phone) Orders (OrderID, CustomerID, EmployeeID, OrderDate, ShippedDate, ShipperID) Employees (EmployeeID, LastName, FirstName) Shippers (ShipperID, ShipperName) Suppliers SupperID CompanyName ContactLastName ContactFirstName Phone 1 Amazon Hamilton Laurell 1231231231 2 Ebay Koontz Dean 1212121212 3 Booksamillion Roberts Nora 1234512345 4 University Carter Stephen 1234567890 Books BookID Title Unit_Price Author Unit_in_Stock SupplierID SubjectsID 1 The Quickie 15.94 James 5 3 1 2 Blaze 13.24 Richard 2 3 1 3 The Navigator 14.01 Clive 10 2 1 4 Birmingham 19.99 Tim 12 3 2 5 North Carolina Ghosts 7.95 Lynne 5 2 2 6 Why I still live in Louisiana 5.95 Ellen 30 1 3 7 The World Is Flat 30 Thomas 17 3 4 Subjects SubjectID CategoryName 1 Fiction 2 History 3 Travel 4 Technology Employees EmployeeID LastName FirstName 1 Larson Erik 2 Steely John Shippers ShipperID ShpperName 1 UPS 2 USPS 3 FedEx Customers CustomerID LastName FirstName Phone 1 Lee James 1111111111 2 Smith John 2222222222 3 See Lisa 3333333333 4 Collins Jackie 4444444444 Orders OrderID CustomerID EmployeeID OrderDate ShippedDate ShipperID 1 1 1 08/01/08 08/03/08 1 2 1 2 08/04/08 NULL NULL 3 2 1 08/01/08 08/03/08 2 4 4 2 08/04/08 08/05/08 1 OrderDetails BookID OrderID Quantity 1 1 2 4 1 1 6 2 2 7 2 3 5 3 1 3 4 1 4 4 1 7 4 1 I am using MySQL locally so I loaded all the data into the tables using .txt files, I was able to do so successfully. Now I am trying to query and am running into all types of problems. I have about 15 queries that I need to run. 1) Show me the titles of all the books which have more than 5 units in stock. I was able to do this one, no problems SELECT B.Title FROM Books B WHERE B.Unit_in_stock > 5; 2) Show me the total price John Smith has paid for the books. I can get the right answer with this one but I know it is not the most "optimized" answer SELECT B.Unit_Price AS Total FROM Books B, Customers C, Orders O WHERE B.BookID=5 AND C.CustomerID=2 AND O.OrderID=2; 3) Show me the name of the customer who has paid less than $20 in total. This is where I start to have problems. I have only been using MySQL for a month so i'm confused on how to get this one to work. 4) Show me the names of all the books shipped on 08/04/08 and their shippers. 5) Show me the names of all the books Erik Larson was responsible for. 6) Show me the total price each customer paid and their names. List the result in the descending price. 7) Show me the unique names of all the books John Smith and Jackie Collins ordered. 8) Show me the names of all the ordered books and their total quantities. List the result in the ascending quantity. 9) Show me the names of all the books shipped by UPS. 10) Show me the names of all the books supplied by Ebay. 11) Show me the names of the customers who ordered at least a book whose name includes Louisiana. 12) Show me the name of the customer who has ordered at least one book written by Thomas. 13) Show me the name of the customer who has ordered at least a travel book and the book names. 14) Show me the name of each category and the cheapest price of the books in that category. 15) Show me the names of customers who have ordered multiple (more than 1) books and the corresponding quantities. List the result in the descending quantity.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

Explain three broad global HR challenges.

Answered: 1 week ago

Question

Which team solution is more likely to be pursued and why?

Answered: 1 week ago

Question

Did the team members feel that their work mattered

Answered: 1 week ago