Changes between Initial Version and Version 1 of View4


Ignore:
Timestamp:
08/21/26 08:48:20 (26 hours ago)
Author:
235018
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • View4

    v1 v1  
     1= Employee workload and salary report
     2
     3=== Description
     4This view provides an overview of employee working hours, wages, payment methods, and the stores where employees work.
     5
     6The view is intended for:
     7
     8- monitoring employee workload
     9- calculating and reviewing employee wages
     10- payroll reports
     11- analyzing employee work across stores
     12
     13==== Tables covered by the view:
     14
     15- Personal
     16- Employees
     17- Store
     18- works_in_store
     19- worked
     20
     21==== SQL код
     22{{{#!sql
     23CREATE OR REPLACE VIEW vw_employee_workload_salary AS
     24SELECT
     25    e.id AS employee_id,
     26    p.first_name,
     27    p.last_name,
     28    p.email,
     29    e.date_of_hire,
     30
     31    s.store_id,
     32    s.name AS store_name,
     33
     34    w.week,
     35    w.total_week,
     36    w.working_hours,
     37    w.wage,
     38    w.pay_method
     39
     40FROM employees e
     41JOIN personal p
     42    ON p.id = e.id
     43JOIN works_in_store wis
     44    ON wis.id = e.id
     45JOIN store s
     46    ON s.store_id = wis.store_id
     47LEFT JOIN worked w
     48    ON w.id = e.id
     49    AND w.store_id = wis.store_id;
     50
     51}}}
     52
     53==== Logic explanation
     54**1.** The `employees` table identifies personnel who are employees.
     55**2.** The `personal` table provides their personal information.
     56**3.** The `works_in_store` relationship identifies the store where each employee works.
     57**4.** The `store` table provides the store name and identifier.
     58**5.** The `worked` relationship provides working hours, weekly totals, wage, and payment method.
     59**6.** LEFT JOIN is used for `worked` so that an employee can still appear even if no work-report record has yet been entered.
     60
     61==== Reason for view
     62This view is useful because:
     63
     64- It combines employee, store, working-hour, and wage information
     65- It simplifies payroll-related queries
     66- It allows managers to monitor employee workload
     67- It provides a consistent source for employee work reports
     68- It avoids repeatedly joining five different tables
     69
     70Without this view employers have to manually track employees workload and payroll, using many JOINTs on multiple occasions and with that overloading the system.