Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.
-
Upload
brianna-valerie-craig -
Category
Documents
-
view
215 -
download
1
Transcript of Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.
![Page 1: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/1.jpg)
Team #2A DATABASE FOR LA
GAUGE COMPANY
Benn AckleyAjay Bawa
Clarence CheungSteven Leonard
Nhat NguyenEdrick Soetanto
![Page 2: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/2.jpg)
Company Background Customer Request EER Diagram Relational Schema Normalization Analysis Forms and Reports Query implementation Future improvement
Today’s Agenda
![Page 3: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/3.jpg)
Location: Sun Valley, CA
Provides ultra precision machining of Beryllium Alloys and other exotic metals used in aerospace, defense, optics, and nuclear industries.
Major clients:◦ Boeing◦ Northrop Grumman◦ Raytheon
Company Background
![Page 4: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/4.jpg)
Current database: Delmar- a 16-bit legacy database
Difficulty with current database: ◦ Slow and unreliable◦ Many glitches◦ High maintenance cost
To create a database allowing:◦ LA Gauge engineers to effectively communicate with the
floor machinists and keep track of the work flows. ◦ Easy input of series of operations and specifications to
machine a product. ◦ Sales Associate to input customer and order data
Estimated data size: 5,000 – 10,000 records.
Customer Request
![Page 5: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/5.jpg)
EER Diagram
![Page 6: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/6.jpg)
Relational Schema1. Customer (Customer_ID, Company, Lname, Fname, Email, Job_Title,
Business_Phone, Street_Address, City, State, ZIP, Country, Web_Page, Primary_liaison7)
2. Order(Order_ID, Order_Date, Customer_ID1)3. Product(Product_ID, Product_Name, Description, Product_Sales_Price,
Amount_On_Hand, Order_ID2)1. Purchased(Product_ID, Purchased_Cost, Purchased_Date, Supplier_ID5) 2. In-House(Product_ID, Manufacturing_Cost, Manufacturing_Date,)
4. Shipment(Shipment_ID, Tracking_Number, EID7a)1. Ship_In(Shipment_ID, Supplier_ID5, Received_Date, Receiving_Employee7, RM_ID6)2. Ship_Out(Shipment_ID, Customer_ID1, Shipped_Date, Shipping_Cost)
5. Supplier(Supplier_ID, Company, Lname, Fname, Email, Job_Title, Business_Phone, Business_Phone, Street_Address, City, State, Province, ZIP, Country, Web_Page, Account_ID23)
6. Raw_Material(RM_ID, RM_Name , Description, RM_Cost, Supplier_ID5, Shipment_ID4, Account_ID23, Amount_On_Hand, Units, Amount_Purchase )
7. Employee(Employee_ID, Lname, Fname, Email, Phone, Streeet_Address, City, State, ZIP, Country, Schedule, Working_Hour, Department_ID12, Starting_Date, Salary, Supervisor7)
a) Sales_Associate(Employee_ID, Commission)b) Technician(Employee_ID)c) Other(Employee_ID, Job_Duty)
8. Job(Job_ID, Job_Name, Job_Description, Tech_ID7b, Product_ID3b, Employee_Modify7b, Modifying_Date)
![Page 7: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/7.jpg)
9. File(File_ID, File_Name, File_Description, Tech_ID7b, Modifier7b, Created_Date, Modifying_Date, Job_ID8)
10. Procedure(Procedure_ID, Job_ID8, Procedure_Name, Description, File_ID9)
11. Operation(Operation_ID, Procedure_ID, Job_ID8, Description, Operation_Name, WorkCenter_ID13 , Hardware_ID14)
12. Department(Department_ID, Department_Name, Department_Location, Department_Phone)
13. WorkCenter(WorkCenter_ID, WorkCenter_Name, Description, Location, WorkCenter_Capacity, Operating _Hours, Managing_Department12)
14. Hardware(Hardware_ID, Hardware_Name, Hardware_Description, Hardware_Usage_Period, Hardware_Size, Hardware_Weight, Hardware_Brand, WorkCenter_ID13, Operation_ID11)
9. Tool_Type(Hardware_ID, Replacement_Period)
10. Machine_Type(Hardware_ID, Machine_name, Description, Cost)
15. Tool_Token (Tool_Token_ID, Tool_Token_Name, Quantity, Hardware_ID14a)
16. Machine_Token(Machine_Token_ID, Machine_Token_Name, Quantity, Hardware_ID)
17. Product_components(Product_ID3, Component_ID3, Quantity)
18. Is_authorized_to_use(Hardware_ID14b, Tech_ID7b)
19. Request (Order_ID2, Product_ID3, quantity)
20. Is_Composed_Of (Product_ID3, RM_ID6)
21. LA_Gauge_Account (Payment_ID, Order_ID2, Customer_ID1, Amount, Due_Date, Date_Of_Payment, Penalty)
22. Machine_Status(Machine_ID14b, Inspection_Date, Status)
23. Product_Materials(Product_ID14b, RM_ID, Quantity)
Relational Schema
![Page 8: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/8.jpg)
RELATIONAL SCHEMA: 1:1 RELATIONSHIP
8. Job(Job_ID, Job_Name, Job_Description, Product_ID3b, Employee_Modify7b, Modifying_Date)
![Page 9: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/9.jpg)
RELATIONAL SCHEMA: 1:N RELATIONSHIP
7. Employee(Employee_ID, Lname, Fname, Email, Job_Title, Phone_Address, Streeet_Address, City, State, ZIP, Country, Schedule, Working_Hour, Department_ID12, Starting_Date, Supervisor7)
a. Sales_Associate(Employee_ID, Commission)
b. Technician(Employee_ID, Salary)c. Others (Employee_ID, Wage, Job_Duty)
![Page 10: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/10.jpg)
MS Access Relationship View
![Page 11: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/11.jpg)
In 1NF: ◦Procedure(Procedure_ID, Job_ID, Procedure_Name, Description, File_ID)Functional Dependencies:◦ FD1: {Procedure_ID} {Procedure_Name}◦ FD2: {Procedure_ID, Job_ID} {File_ID}
In 2NF: ◦Procedure1(Procedure_ID, Job_ID, File_ID)◦Procedure2(Procedure_ID, Procedure_Name, Description)
The relations are in 2NF and satisfy both 3NF and BCNF requirements as well
Normalization 1 (1NF)
![Page 12: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/12.jpg)
In 1NF:Operation(Operation_ID, Procedure_ID, Job_ID, Description, Operation_Name, WorkCenter_ID, Hardware_ID)◦Functional Dependencies:
FD1: Operation_ID {Description, Operation_Name} FD2: {Operation_ID, Procedure_ID, Job_ID} {WorkCenter_ID,
Hardware_ID} FD3: Hardware_ID WorkCenter_ID
In 2NF:◦Operation1(Operation_ID, Procedure_ID, Job_ID, WorkCenter_ID, Hardware_ID)◦Operation2(Operation_ID, Description, Operation_Name)
Normalization 2 (1NF)
![Page 13: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/13.jpg)
In 3NF:◦ Operation1A(Operation_ID, Procedure_ID,
Job_ID, Hardware_ID)◦ Operation1B(Hardware_ID, Workcenter_ID)
The relations are in BCNF too
Normalization 2 (1NF)
![Page 14: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/14.jpg)
In 2NF:LA_Gauge_Account ( Account_ID, Amount, Date, Order_ID, Customer_ID)Functional Dependencies:
FD1: Account_ID {Amount, Date, Order_ID, Customer_ID} FD2: Order_ID Customer_ID
In 3NF:◦LA_Gauge_Account1(Account_ID, Amount, Date, Order_ID)◦LA_Gauge_Account 2(Order_ID, CustomerID)
The relations are in BCNF too
Normalization 3 (2NF)
![Page 15: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/15.jpg)
In 3NFDepartment (Department_ID, Department_Name, Department_Location, Department_Phone)◦Functional Dependencies:
FD1: Department_ID {Department_Name, Department_Location, Department_Phone}
FD2: {Department_Name, Department_Location} Department_ID FD3: {Department_Phone} {Department_Location}
In BCNF: ◦Department1(Department_ID, Department_Name, Department_Phone)◦Department2(Department_Phone, Department_Location)
Normalization 4 (3NF)
![Page 16: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/16.jpg)
In BCNFOrder(Order_ID, Order_Date, Customer_ID)Functional Dependencies:FD1: Order_ID {Order_Date, Customer_ID}
Normalization 5 (BCNF)
![Page 17: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/17.jpg)
Switchboard
![Page 18: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/18.jpg)
Form: Add new customer
![Page 19: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/19.jpg)
Form: Add new job
![Page 20: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/20.jpg)
Report: Customer Payment Account
![Page 21: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/21.jpg)
Report: Employee salary
![Page 22: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/22.jpg)
Functions: ◦ To indicate if any of the raw material is out of stock. ◦ To compute the optimal order amount using the
Economic Oder Quantity (EOQ)
Purposes: ◦ Help the sales department order the out-of-stock items
ASAP minimize any possible delays & start the production process on time
◦ Help decrease the storage cost and increase the company’s cash flow.
QUERY 1: Optimal Order Quantity
![Page 23: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/23.jpg)
EOQ model assumptions:◦ Fixed cost is 100$ and holding cost is 10%
material price◦ Deterministic demand
Q*: optimal order quantity D: the product’s demand rateS: fixed cost per orderH: annual holding cost per unit of product
MS Access Implementation
![Page 24: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/24.jpg)
SELECT sub.*, SQR(2*sub.demand*100/(0.1*sub.rm_cost)) AS reorder_quantity
FROM (SELECT rm.rm_id, rm.amount_on_hand, rm.rm_cost, (rm.amount_purchased-rm.amount_on_hand)/DATEDIFF('ww',s.received_date,DATE()) AS demand, s.received_date FROM Raw_Material AS rm LEFT JOIN Ship_In AS s ON s.rm_id=rm.rm_id) AS sub
WHERE sub.amount_on_hand<=sub.demand;
Implementation
![Page 25: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/25.jpg)
Functions: ◦ To sums up the total usage time of each machine
starting from its first operation◦ To estimate the remaining service time (the survival
period) of each machine using the survival analysis.
Purposes: ◦ Help the maintenance team determines when a
check-up or a replacement is necessary
◦ Help the financial department and the executive committee in distributing future investment accordingly (since a machine may cost up to million dollars)
QUERY 2 : Machine’s usage time and maintenance schedule
![Page 26: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/26.jpg)
Option Compare Database
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim mySQL As String
mySQL = "SELECT [Inspection_date], [status] INTO
m_status FROM machine_status WHERE [machine_id] = 1"
DoCmd.RunSQL mySQL
DoCmd.TransferText acExportDelim,
TableName:=“m_status",
File:="C:\machine_status.csv",
HasFieldNames:=True
Shell("c:\run_cox_survival.R", 1)
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
Implementation
![Page 27: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/27.jpg)
Integrate our database with a job scheduling package◦ Record job start and stop times to determine historic
operation duration◦ Analyze whether SPT or Moore’s Algorithm is more efficient
Provide job tracking report for customers to view online◦ They would always know where their product was and who
was working on it◦ Could also be used by management to snapshot the factory
status
Iterate with test users to obtain feedback and refine the database
Users would identify additional functionality and workflows
Future Improvements
![Page 28: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/28.jpg)
Functions: To rank each product based on its service category from the highest profitability to the lowest ones.
Purposes: ◦ The marketing department could recruit more customers
interested in purchasing the top profitable products.
◦ The financial department can distribute more investment into advancing the current technology of that given services improves the product’s quality and attracts more customers.
QUERY 3: Product’s profitability ranking
![Page 29: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/29.jpg)
SELECT ptop.product_id, (ptop.product_sales_price - pc_sub.cost - pm_sub.cost) AS profit
FROM (product AS ptop LEFT JOIN (SELECT p.product_id, SUM(p2.product_sales_price * pc.quantity) AS costFROM ( (product pLEFT JOIN product_components pcON pc.product_id = p.product_id )LEFT JOIN product p2ON pc.component_id = p2.product_id )GROUP BY p.product_id ) AS pc_sub ON pc_sub.product_id = ptop.product_id) LEFT JOIN (SELECT p.product_id, SUM(rm.rm_cost * pm.quantity) AS costFROM ( (product pLEFT JOIN product_materials pmON pm.product_id = p.product_id )LEFT JOIN raw_material rmON rm.rm_id = pm.rm_id )GROUP BY p.product_id ) AS pm_sub ON pm_sub.product_id = ptop.product_id
ORDER BY ptop.product_sales_price - pc_sub.cost - pm_sub.cost DESC;
SQL
![Page 30: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/30.jpg)
Access Implementation:
![Page 31: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/31.jpg)
Functions: ◦ To sort out all of the different works centers needed
to perform a given job and rank them according to the job’s priority
◦ Within one work center, lists out the operating hours of each machine along with the names of the technicians who are authorized to operate that type of machines.
Purposes: ◦ To help the scheduling department ease down the
difficulties in scheduling the work centers and the technicians’ working schedule
◦ Increase productivity
QUERY 4: Operating hours and scheduling
![Page 32: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/32.jpg)
4a. SELECT p.procedure_name, p.description, f.file_nameFROM [procedure] AS p LEFT JOIN file AS f ON
f.File_id=p.File_IDWHERE p.job_id=job;4b. SELECT o.operation_name, o.description,
w.workcenter_name, h.hardware_nameFROM (([procedure] AS p LEFT JOIN operation AS o ON
o.procedure_id=p.procedure_id) LEFT JOIN workcenter AS w ON w.workcenter_id=o.workcenter_id) LEFT JOIN hardware AS h ON h.hardware_id=o.hardware_id
WHERE p.job_id=job;
SQL (4a & 4b)
![Page 33: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/33.jpg)
4c.SELECT e.fname, e.lname, tech.cntFROM employee AS e LEFT JOIN (SELECT a.tech_id, COUNT(*) AS cnt FROM
((job AS j LEFT JOIN [procedure] AS p ON p.job_id=j.job_id) LEFT JOIN operation AS o ON o.procedure_id=p.procedure_id) LEFT JOIN is_authorized_to_use AS a ON a.hardware_id=o.hardware_id WHERE j.job_id=job GROUP BY a.tech_id) AS tech ON tech.tech_id=e.employee_id
WHERE tech.cnt>0ORDER BY tech.cnt DESC;
4d.SELECT p.product_name, p.description, pc.quantity, p.product_sales_priceFROM (job AS j LEFT JOIN product_components AS pc ON
pc.product_id=j.product_id) LEFT JOIN product AS p ON p.product_id=pc.component_id
WHERE j.job_id=job;
SQL (4c & 4d)
![Page 34: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/34.jpg)
Access Implementation: List out the work center & operation
![Page 35: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/35.jpg)
Access Implementation: List out the work center & operation
![Page 36: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/36.jpg)
Access Implementation: List out the procedures & files
![Page 37: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/37.jpg)
List out the employees authorized to use a certain hardware
![Page 38: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/38.jpg)
List out the employees authorized to use a certain hardware (cont)
![Page 39: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/39.jpg)
List out which job correspond to which product
![Page 40: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/40.jpg)
Function: To rank all of the sales associates (SA) according to their effectiveness index, which is calculated as the ratio of the profits made from all of the orders that employee makes during that year to their base salary.
Function:◦Help the human resources department compute the employees’ year-end bonuses and reward the SAs with a high effectiveness index accordingly.
QUERY 5: Sales Associate’s effectiveness ranking
![Page 41: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/41.jpg)
SELECT e.fname, e.lname, sub.total_sales / e.salary AS profitabilityFROM (SELECT c.primary_liason, SUM(o_amt.order_total) AS total_sales
FROM ( ( [order] o LEFT JOIN (
SELECT r.order_id, SUM(r.quantity * p.product_sales_price) AS order_total
FROM request rLEFT JOIN product pON p.product_id = r.product_idGROUP BY r.order_id ) o_amt
ON o.order_id = o_amt.order_id )LEFT JOIN [customer] cON o.customer_id = c.customer_id )WHERE o.order_date >= DATEADD('yyyy', -3, DATE())GROUP BY c.primary_liason ) AS sub LEFT JOIN employee AS e ON e.employee_id = sub.primary_liason
ORDER BY sub.total_sales / e.salary DESC;
SQL
![Page 42: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/42.jpg)
Access Implementation:
![Page 43: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/43.jpg)
Question?
![Page 44: Benn Ackley Ajay Bawa Clarence Cheung Steven Leonard Nhat Nguyen Edrick Soetanto.](https://reader036.fdocuments.net/reader036/viewer/2022062717/56649e455503460f94b39af6/html5/thumbnails/44.jpg)
Thank You