OMIS-652 Database Development Project

Post on 13-Apr-2017

32 views 4 download

transcript

NORTHERN ILLINOIS

UNIVERSITY

OMIS 652

Business Applications of Database Management System

3rd Deliverable - Database Diagram & Queries

Submitted by,

Akarsh Vinod Ghanathay (Z1804713)

Nikhilesh Methuku (Z1807570)

Shaik Nisar Ahmed (Z1780816)

Syed Mahmood Hasan (Z1774742)

The Database Diagram

Intern Table

Catalog table

Customer table

Employee table

Inventory requirement order table

Inventory details table

Logistic partner table

Order table

Payment table

Product table

Raw material table

Shipping table

Supplier table

Workshop table

1. Write a query to find the employeeid and customerid whose name matches with customer’sfirst

name?

select e.empid,c.cusid,e.name from final_employee e join final_order o on e.orderID = o.orderID join final_customer c on o.cusID = c.cusID and e.name=c.fname

2. Write a query to display customer id, first name and last name of all the customers who were involved

in more than one purchase.

select cusID, fname, lname from final_customer where cusID in (select cusID from final_order group by cusID having count (cusID)>1)

3. Write a query to display the total sum of sales for each product type

select p.productType, sum(o.price) from final_product p join final_order o on p.productID = o.productID group by p.productType

4. Write a query to find the list of customers with their id, firstname, lastname who have purchased shoes

that are made of ‘leather’.

select cusID, fname, lname from final_customer where cusID in (select cusID from final_order where orderID in ( select orderID from final_product where material like 'leather'))

5. Write a query to display name of the logistic partner who delivered the synthetic products.

select name from final_logistics where logisticID in ( select logisticID from final_shipping where orderID in ( select orderID from final_order where productID in ( select productID from final_product where material='synthetic')))

6. Display the name of employees who were involved in manufacturing orders in workshop type

‘backpack’.

Select name From final_employee Where empID in ( Select empID From final_workshop Where workshoptype = 'backpack')

7. List the name of the material which is supplied from California.

select name from final_rawmaterial where materialID in ( select materialID from final_intventoryrequireorder where requirementorderID in ( select requirementorderID from final_supplier where location = 'california'))

8. List the highest quote for leather.

select s.requirementorderID, MAX(quote) from final_supplier s join final_intventoryrequireorder i on s.requirementorderID=i.requirementorderID join final_rawmaterial f on i.materialID = f.materialID and f.name = 'leather' group by s.requirementorderID

9. Find the name of the raw material which was procured by the supplier id ‘401’.

select name from final_rawmaterial where materialID in ( select materialID from final_intventoryrequireorder where requirementorderID in ( select requirementorderID from final_supplier where supplierID = 401))

10. Find the status of the order by the employee name ‘Show’.

select status from final_shipping where orderID in (select orderID from final_employee where orderID in (select orderID from final_employee where name = 'show'))

11. Write a query to display the logistic partner who delivered the digital leather watch.

select name from final_logistics where logisticID in ( select logisticID from final_shipping where orderID in ( select orderID from final_order where productID in ( select productID from final_product where material='leather' and [desc]='digital')))

12. Write a query to display the employee who processed the orders that were delivered by DHL.

select empID, e.name, l.name from final_employee e, final_order o, final_shipping s, final_logistics l where e.orderID = o.orderID and o.orderID = s.orderID and s.logisticID = l.logisticID and l.name = 'DHL'

13. Display the list of intern that worked on watches

select i.name from final_intern i, final_workshop w, final_employee e, final_order o, final_product p where i.orderID = w.orderID and w.orderID = e.orderID and e.orderID = o.orderID and o.productID = p.productID and productType = 'watch'

14. List the Number of transactions with watches.

select productType, count(transactionID) as NumberofTransactions from final_payment p, final_order o, final_product pr where p.orderID = o.orderID and o.productID = pr.productID and productType = 'watch' group by productType

15. List the Number of orders delivered by DHL.

select i.name as interName, e.name employeeName, e.empID from final_intern i, final_employee e, final_workshop w where i.workshopID = w.workshopID and e.empID = w.empID and i.name = e.name

16. List the name of the inventory where synthetic materials are stored.

select name from final_inventory_details where inventoryID in ( select inventoryID from final_rawmaterial where name = 'synthetic')

17. List the name of the products whose inventory was are stored in north.

select name, [desc],productID from final_product where materialID in ( select materialID from final_rawmaterial where inventoryID in ( select inventoryID from final_inventory_details where name = 'north'))

18. List the name of the supplierID who supplies leather.

select supplierid from final_supplier where requirementorderID in ( select requirementorderID from final_intventoryrequireorder where materialID in ( select materialID from final_rawmaterial where name = 'leather'))

19. Write a query to display the customer id who bought leather bags.

select cusid from final_customer where cusID in ( select cusID from final_order where productID in ( select productID from final_product where productType = 'bag' and material = 'leather'))

20. Display the transaction id that dealt with customer first name sam.

select transactionid from final_payment where cusID in ( select cusID from final_customer where fname = 'sam')