+ All Categories
Home > Documents > Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind...

Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind...

Date post: 03-Apr-2021
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
9
Page | 1 Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017 Assignment #2 – MySQL Due: February 22, 2017 at 5:59 p.m. Instructions: Using the Northwind Database schema, write queries that will return the following data: Upload a Word document (you may modify this one) to the assignment in Canvas 1. An alphabetical list of shippers and their phone numbers. 2. A list of the employees and their title that reside in London. 3. A list of products, their unit price, and units ordered by the customer B’s Beverages. 4. A list of all products, the supplier name, supplier contact, and phone of products no longer in stock. 5. List the supplier name, phone, and category name for all dairy and meat/poultry products that have been discontinued. 6. List all employees and their extension that have customers in Mexico, Brazil, or Argentina. 7. List all orders that are shipped to regions in which Northwind has suppliers. 8. List all supplier regions that have orders shipped to them.
Transcript
Page 1: Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind Database schema, write queries that will return the following data: Upload a Word

P a g e | 1

Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017

Assignment #2 – MySQL

Due: February 22, 2017 at 5:59 p.m.

Instructions:

Using the Northwind Database schema, write queries that will return the following data:

Upload a Word document (you may modify this one) to the assignment in Canvas

1. An alphabetical list of shippers and their phone numbers. 2. A list of the employees and their title that reside in London. 3. A list of products, their unit price, and units ordered by the customer B’s Beverages. 4. A list of all products, the supplier name, supplier contact, and phone of products no

longer in stock. 5. List the supplier name, phone, and category name for all dairy and meat/poultry

products that have been discontinued. 6. List all employees and their extension that have customers in Mexico, Brazil, or

Argentina. 7. List all orders that are shipped to regions in which Northwind has suppliers. 8. List all supplier regions that have orders shipped to them.

Page 3: Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind Database schema, write queries that will return the following data: Upload a Word

P a g e | 3

Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017

3.

SELECT c.CompanyName, p.ProductID, p.ProductName, ord.UnitPrice, p.UnitsOnOrder, p.QuantityPerUnit, o.OrderDate

FROM products AS p, `order details` AS ord, customers AS c, orders AS o WHERE ( p.ProductID = ord.ProductID AND ord.OrderID = o.OrderID

AND o.CustomerID = c.CustomerID AND c.CompanyName = "B's Beverages"

)

LIMIT 0 , 30

Page 4: Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind Database schema, write queries that will return the following data: Upload a Word

P a g e | 4

Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017

4.

SELECT p.ProductID, p.ProductName, s.SupplierID, s.CompanyName, s.ContactNa

me, s.ContactTitle, s.Phone

FROM products AS p

INNER JOIN suppliers AS s ON ( p.SupplierID = s.SupplierID

AND p.discontinued = '1' )

LIMIT 0 , 30

aqumarti
Sticky Note
discontinued != unitsinstockSELECT p.ProductID, p.ProductName, s.SupplierID, s.CompanyName, s.ContactName, s.ContactTitle, s.Phone FROM products AS p INNER JOIN suppliers AS s ON ( p.SupplierID = s.SupplierID AND p.unitsinstock = '0' )
Page 5: Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind Database schema, write queries that will return the following data: Upload a Word

P a g e | 5

Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017

5.

SELECT s.ContactName, s.ContactTitle, s.CompanyName, s.Phone, cat.CategoryNa

me, p.ProductID FROM suppliers AS s, categories AS cat, products AS p

WHERE (p.SupplierID = s.SupplierID) AND (p.CategoryID = cat.CategoryID) AND (cat.CategoryName = "Dairy Products"

OR cat.CategoryName = "Meat/Poultry") AND p.discontinued = '1'

LIMIT 0 , 30

6.

SELECT e.Title, e.TitleOfCourtesy, e.FirstName, e.LastName, e.Extension, o.EmployeeID, c.CustomerID, c.ContactName, c.Country

FROM employees AS e, orders AS o, customers AS c WHERE

(e.EmployeeID = o.EmployeeID) AND (o.CustomerID = c.CustomerID)

AND ( c.Country = "Mexico" OR c.Country = "Brazil" OR c.Country = "Argentina"

) LIMIT 0 , 30

aqumarti
Sticky Note
(-.25) your query includes duplicates - the query does not require customerid, contact name or countrySELECT distinct e.Title, e.TitleOfCourtesy, e.FirstName, e.LastName, e.Extension, o.EmployeeID FROM employees AS e, orders AS o, customers AS c WHERE (e.EmployeeID = o.EmployeeID) AND (o.CustomerID = c.CustomerID) AND ( c.Country = "Mexico" OR c.Country = "Brazil" OR c.Country = "Argentina" )
Page 6: Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind Database schema, write queries that will return the following data: Upload a Word

P a g e | 6

Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017

7.

SELECT o.OrderID, ord.Quantity, p.ProductName, s.CompanyName, s.Region, s.Country FROM orders AS o, `order details` AS ord, products AS p, suppliers AS s

WHERE (o.OrderID = ord.OrderID) AND (ord.ProductID = p.ProductID)

AND (p.SupplierID = s.SupplierID) LIMIT 0 , 30

aqumarti
Sticky Note
-.25 select distinct to remove duplicates
Page 7: Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind Database schema, write queries that will return the following data: Upload a Word

P a g e | 7

Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017

8.

SELECT p.SupplierID, s.City, s.Region, s.Country, o.OrderID, p.ProductName, ord.UnitPrice, p.QuantityPerUnit, o.OrderDate

FROM suppliers AS s, products AS p, `order details` AS ord, orders AS o WHERE

((s.supplierID = p.SupplierID) AND (p.ProductID = ord.ProductID) AND (ord.OrderID = o.OrderID))

LIMIT 2130 , 30

aqumarti
Sticky Note
-1 this query is incorrectSELECT distinct s.Region FROM suppliers AS s, orders AS o WHERE (s.region = o.shipregion)
Page 8: Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind Database schema, write queries that will return the following data: Upload a Word

P a g e | 8

Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017

Page 9: Assignment #2 MySQL Due: February 22, 2017 at 5:59 p.m. … · 2017. 5. 1. · Using the Northwind Database schema, write queries that will return the following data: Upload a Word

P a g e | 9

Assignment 2 : Web Database Concepts Swarnamouli Majumdar Spring 2017


Recommended