Skip to content

Mini payroll management system in SQL Server with clean schema design and T-SQL logic.

Notifications You must be signed in to change notification settings

Rika290/Employee-Management-Payroll-System-SQL-Server-T-SQL-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Employee Management & Payroll System – SQL Server (T-SQL)

πŸ“Œ Project Overview:

  • This project demonstrates a complete SQL Server database system for managing employees, departments, payroll, and attendance.
  • It includes database design, data insertion, reporting queries, stored procedures, functions, and indexing.

πŸ›  Tech Stack:

  • SQL Server 2022
  • T-SQL
  • SSMS (SQL Server Management Studio)
  • ERD (Database Diagrams)

βš™οΈ Skills Demonstrated:

  • SQL Server (T-SQL)
  • Database design (3NF)
  • Constraints (PK, FK, CHECK, UNIQUE)
  • DDL + DML scripting
  • Joins, subqueries, CTEs, window functions
  • Stored procedures
  • Scalar functions
  • Indexes (Clustered & Nonclustered)

🧱 Schema Highlights:

πŸ“Œ Dimension Tables:

  • Department β€” Stores department names and codes
  • JobRole β€” Job titles, grades, and department linkage
  • Employee β€” Employee master data (personal + job + department)

πŸ“Œ Fact Tables:

  • Salary β€” Monthly salary structure (basic, HRA, PF, allowances)
  • Attendance β€” Daily login/logout & working days
  • Payroll β€” Final payroll calculations per month per employee

πŸ”— Relationships & Integrity:

  • All tables linked with Primary–Foreign Key relationships
  • Ensures full referential integrity through:
    • employee_id
    • department_id
    • jobrole_id
    • salary_id
  • Implemented CHECK constraints, UNIQUE constraints, and default values (where needed)

πŸ“Έ Snapshots:

πŸ“˜ Data Model Diagram:

Data Model

🧾 Creating and populating tables:

  • Sample records:

Data Tables

πŸ“Š Reporting Queries Implemented:

  • Employee list with department, role, salary
  • Top 3 employees by salary (per department) using RANK()
  • Employees earning above department average
  • Latest salary using ROW_NUMBER()
  • Department-wise payroll
  • Payroll ranking using DENSE_RANK
  • Employees with no payroll
  • Attendance summary per employee
  • Salary vs Department average

πŸ›  Stored Procedures:

  • AddNewEmployee
  • UpdateEmployeeSalary
  • GetDepartmentPayrollReport
  • GetEmployeeTotalPayroll (Output parameter)

πŸ”’ Scalar Functions:

  • GetFullName(EmpID)
  • GetTotalPayroll(EmpID)

⚑ Indexing:

  • Nonclustered index on DepartmentID for faster department-wise queries.
  • Clustered index automatically created on EmployeeID (PK).

πŸ“‚ Project Structure:

  • README.md β†’ Complete project documentation
  • A.EmpPayroll_CreatingTables.sql β†’ Database + 6 table creation scripts
  • B.EmpPayroll_InsertingValues.sql β†’ 50 employee records + salary + attendance + payroll
  • C.EmpPayroll_ReportingQueries.sql β†’ Joins, CTEs, window functions, subqueries
  • D.EmpPayroll_StoredProcedures.sql β†’ CRUD + salary update + payroll summary SPs
  • E.EmpPayroll_Functions.sql β†’ Full name & total payroll scalar functions
  • F.EmpPayroll_Indexes.sql β†’ Nonclustered index on DepartmentID
  • images/ β†’
    • model.jpg β†’ ER diagram showing the relationships between the tables
    • snap.jpg β†’ Snapshot of tables

🧠 Key Learnings:

  • How to design normalized databases (3NF)
  • Writing clean & optimized T-SQL code
  • Using window functions for analytics
  • Designing reusable stored procedures
  • Improving performance with indexes
  • Creating real-world payroll calculations

πŸš€ How to Run This Project

  1. Open SQL Server Management Studio (SSMS)
  2. Run A.EmpPayroll_CreatingTables.sql
  3. Run B.EmpPayroll_InsertingValues.sql
  4. Run reporting queries β†’ C.EmpPayroll_ReportingQueries.sql
  5. Run stored procedures β†’ D.EmpPayroll_StoredProcedures.sql
  6. Run scalar functions β†’ E.EmpPayroll_Functions.sql
  7. Run index creation β†’ F.EmpPayroll_Indexes.sql

About

Mini payroll management system in SQL Server with clean schema design and T-SQL logic.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages