黑狐家游戏

数据库课程设计实例员工管理,数据库课程设计 实例

欧气 1 0

构建高效员工管理系统的数据库设计与实现

一、引言

员工管理是企业运营中至关重要的环节,它涉及到员工的基本信息、考勤记录、绩效评估、薪资待遇等多个方面,一个高效的员工管理系统不仅可以提高企业的管理效率,还可以为企业的决策提供有力的支持,本课程设计实例将以员工管理为主题,介绍如何使用数据库技术构建一个功能完善的员工管理系统。

二、需求分析

在进行数据库设计之前,我们需要对员工管理系统的需求进行详细的分析,通过与企业相关人员的沟通和调研,我们可以了解到员工管理系统需要实现以下功能:

1、员工信息管理:包括员工的基本信息、联系方式、职位信息等。

2、考勤管理:记录员工的出勤情况,包括请假、加班、迟到、早退等。

3、绩效评估管理:对员工的工作表现进行评估,包括工作任务完成情况、工作质量、工作效率等。

4、薪资待遇管理:计算员工的薪资待遇,包括基本工资、绩效工资、奖金、福利等。

5、报表统计分析:生成各种报表,如员工考勤报表、绩效评估报表、薪资报表等,以便企业进行管理和决策。

三、数据库设计

根据需求分析的结果,我们可以设计出以下的数据库表结构:

1、员工信息表(employees)

员工编号(employee_id):主键,自增。

员工姓名(employee_name):非空。

性别(gender):非空。

出生日期(birth_date):非空。

联系方式(contact_info):非空。

职位编号(position_id):外键,关联职位表。

2、职位表(positions)

职位编号(position_id):主键,自增。

职位名称(position_name):非空。

职位描述(position_description):非空。

3、考勤记录表(attendance_records)

考勤记录编号(attendance_record_id):主键,自增。

员工编号(employee_id):外键,关联员工信息表。

考勤日期(attendance_date):非空。

出勤状态(attendance_status):非空,取值为“正常”、“请假”、“加班”、“迟到”、“早退”。

4、绩效评估表(performance_evaluations)

绩效评估编号(performance_evaluation_id):主键,自增。

员工编号(employee_id):外键,关联员工信息表。

评估日期(evaluation_date):非空。

评估得分(evaluation_score):非空。

评估等级(evaluation_level):非空,取值为“优秀”、“良好”、“合格”、“不合格”。

5、薪资表(salaries)

薪资编号(salary_id):主键,自增。

员工编号(employee_id):外键,关联员工信息表。

薪资计算日期(salary_calculation_date):非空。

基本工资(basic_salary):非空。

绩效工资(performance_salary):非空。

奖金(bonus):非空。

福利(benefits):非空。

6、报表统计分析表(reports)

报表编号(report_id):主键,自增。

报表名称(report_name):非空。

报表数据(report_data):非空。

四、数据库实现

在完成数据库设计之后,我们可以使用 SQL 语言来实现数据库,以下是一个使用 MySQL 数据库实现员工管理系统的示例代码:

-- 创建员工信息表
CREATE TABLE employees (
    employee_id INT AUTO_INCREMENT PRIMARY KEY,
    employee_name VARCHAR(50) NOT NULL,
    gender ENUM('男', '女') NOT NULL,
    birth_date DATE NOT NULL,
    contact_info VARCHAR(100) NOT NULL,
    position_id INT NOT NULL,
    FOREIGN KEY (position_id) REFERENCES positions(position_id)
);
-- 创建职位表
CREATE TABLE positions (
    position_id INT AUTO_INCREMENT PRIMARY KEY,
    position_name VARCHAR(50) NOT NULL,
    position_description VARCHAR(200) NOT NULL
);
-- 创建考勤记录表
CREATE TABLE attendance_records (
    attendance_record_id INT AUTO_INCREMENT PRIMARY KEY,
    employee_id INT NOT NULL,
    attendance_date DATE NOT NULL,
    attendance_status ENUM('正常', '请假', '加班', '迟到', '早退') NOT NULL,
    FOREIGN KEY (employee_id) REFERENCES employees(employee_id)
);
-- 创建绩效评估表
CREATE TABLE performance_evaluations (
    performance_evaluation_id INT AUTO_INCREMENT PRIMARY KEY,
    employee_id INT NOT NULL,
    evaluation_date DATE NOT NULL,
    evaluation_score DECIMAL(5, 2) NOT NULL,
    evaluation_level ENUM('优秀', '良好', '合格', '不合格') NOT NULL,
    FOREIGN KEY (employee_id) REFERENCES employees(employee_id)
);
-- 创建薪资表
CREATE TABLE salaries (
    salary_id INT AUTO_INCREMENT PRIMARY KEY,
    employee_id INT NOT NULL,
    salary_calculation_date DATE NOT NULL,
    basic_salary DECIMAL(10, 2) NOT NULL,
    performance_salary DECIMAL(10, 2) NOT NULL,
    bonus DECIMAL(10, 2) NOT NULL,
    benefits DECIMAL(10, 2) NOT NULL,
    FOREIGN KEY (employee_id) REFERENCES employees(employee_id)
);
-- 创建报表统计分析表
CREATE TABLE reports (
    report_id INT AUTO_INCREMENT PRIMARY KEY,
    report_name VARCHAR(50) NOT NULL,
    report_data TEXT NOT NULL
);

五、系统功能实现

在完成数据库实现之后,我们可以使用编程语言来实现员工管理系统的功能,以下是一个使用 Python 语言实现员工管理系统的示例代码:

import sqlite3
连接数据库
conn = sqlite3.connect('employees.db')
创建游标
cursor = conn.cursor()
员工信息管理功能
def employee_management():
    # 添加员工信息
    def add_employee():
        employee_name = input('请输入员工姓名:')
        gender = input('请输入员工性别:')
        birth_date = input('请输入员工出生日期:')
        contact_info = input('请输入员工联系方式:')
        position_id = int(input('请输入员工职位编号:'))
        cursor.execute('INSERT INTO employees (employee_name, gender, birth_date, contact_info, position_id) VALUES (?,?,?,?,?)', (employee_name, gender, birth_date, contact_info, position_id))
        conn.commit()
    # 修改员工信息
    def modify_employee():
        employee_id = int(input('请输入要修改的员工编号:'))
        employee_name = input('请输入新的员工姓名:')
        gender = input('请输入新的员工性别:')
        birth_date = input('请输入新的员工出生日期:')
        contact_info = input('请输入新的员工联系方式:')
        position_id = int(input('请输入新的员工职位编号:'))
        cursor.execute('UPDATE employees SET employee_name =?, gender =?, birth_date =?, contact_info =?, position_id =? WHERE employee_id =?', (employee_name, gender, birth_date, contact_info, position_id, employee_id))
        conn.commit()
    # 删除员工信息
    def delete_employee():
        employee_id = int(input('请输入要删除的员工编号:'))
        cursor.execute('DELETE FROM employees WHERE employee_id =?', (employee_id,))
        conn.commit()
    # 查询员工信息
    def query_employee():
        employee_id = int(input('请输入要查询的员工编号:'))
        cursor.execute('SELECT * FROM employees WHERE employee_id =?', (employee_id,))
        employee = cursor.fetchone()
        if employee:
            print('员工编号:', employee[0])
            print('员工姓名:', employee[1])
            print('员工性别:', employee[2])
            print('员工出生日期:', employee[3])
            print('员工联系方式:', employee[4])
            print('员工职位编号:', employee[5])
        else:
            print('未找到该员工信息!')
    # 员工信息管理菜单
    while True:
        print('员工信息管理菜单:')
        print('1. 添加员工信息')
        print('2. 修改员工信息')
        print('3. 删除员工信息')
        print('4. 查询员工信息')
        print('5. 返回主菜单')
        choice = int(input('请选择操作:'))
        if choice == 1:
            add_employee()
        elif choice == 2:
            modify_employee()
        elif choice == 3:
            delete_employee()
        elif choice == 4:
            query_employee()
        elif choice == 5:
            break
        else:
            print('无效的选择,请重新输入!')
考勤管理功能
def attendance_management():
    # 添加考勤记录
    def add_attendance_record():
        employee_id = int(input('请输入员工编号:'))
        attendance_date = input('请输入考勤日期:')
        attendance_status = input('请输入考勤状态:')
        cursor.execute('INSERT INTO attendance_records (employee_id, attendance_date, attendance_status) VALUES (?,?,?)', (employee_id, attendance_date, attendance_status))
        conn.commit()
    # 修改考勤记录
    def modify_attendance_record():
        attendance_record_id = int(input('请输入要修改的考勤记录编号:'))
        employee_id = int(input('请输入新的员工编号:'))
        attendance_date = input('请输入新的考勤日期:')
        attendance_status = input('请输入新的考勤状态:')
        cursor.execute('UPDATE attendance_records SET employee_id =?, attendance_date =?, attendance_status =? WHERE attendance_record_id =?', (employee_id, attendance_date, attendance_status, attendance_record_id))
        conn.commit()
    # 删除考勤记录
    def delete_attendance_record():
        attendance_record_id = int(input('请输入要删除的考勤记录编号:'))
        cursor.execute('DELETE FROM attendance_records WHERE attendance_record_id =?', (attendance_record_id,))
        conn.commit()
    # 查询考勤记录
    def query_attendance_record():
        attendance_record_id = int(input('请输入要查询的考勤记录编号:'))
        cursor.execute('SELECT * FROM attendance_records WHERE attendance_record_id =?', (attendance_record_id,))
        attendance_record = cursor.fetchone()
        if attendance_record:
            print('考勤记录编号:', attendance_record[0])
            print('员工编号:', attendance_record[1])
            print('考勤日期:', attendance_record[2])
            print('考勤状态:', attendance_record[3])
        else:
            print('未找到该考勤记录!')
    # 考勤管理菜单
    while True:
        print('考勤管理菜单:')
        print('1. 添加考勤记录')
        print('2. 修改考勤记录')
        print('3. 删除考勤记录')
        print('4. 查询考勤记录')
        print('5. 返回主菜单')
        choice = int(input('请选择操作:'))
        if choice == 1:
            add_attendance_record()
        elif choice == 2:
            modify_attendance_record()
        elif choice == 3:
            delete_attendance_record()
        elif choice == 4:
            query_attendance_record()
        elif choice == 5:
            break
        else:
            print('无效的选择,请重新输入!')
绩效评估管理功能
def performance_evaluation_management():
    # 添加绩效评估记录
    def add_performance_evaluation_record():
        employee_id = int(input('请输入员工编号:'))
        evaluation_date = input('请输入绩效评估日期:')
        evaluation_score = float(input('请输入绩效评估得分:'))
        evaluation_level = input('请输入绩效评估等级:')
        cursor.execute('INSERT INTO performance_evaluations (employee_id, evaluation_date, evaluation_score, evaluation_level) VALUES (?,?,?,?)', (employee_id, evaluation_date, evaluation_score, evaluation_level))
        conn.commit()
    # 修改绩效评估记录
    def modify_performance_evaluation_record():
        performance_evaluation_id = int(input('请输入要修改的绩效评估记录编号:'))
        employee_id = int(input('请输入新的员工编号:'))
        evaluation_date = input('请输入新的绩效评估日期:')
        evaluation_score = float(input('请输入新的绩效评估得分:'))
        evaluation_level = input('请输入新的绩效评估等级:')
        cursor.execute('UPDATE performance_evaluations SET employee_id =?, evaluation_date =?, evaluation_score =?, evaluation_level =? WHERE performance_evaluation_id =?', (employee_id, evaluation_date, evaluation_score, evaluation_level, performance_evaluation_id))
        conn.commit()
    # 删除绩效评估记录
    def delete_performance_evaluation_record():
        performance_evaluation_id = int(input('请输入要删除的绩效评估记录编号:'))
        cursor.execute('DELETE FROM performance_evaluations WHERE performance_evaluation_id =?', (performance_evaluation_id,))
        conn.commit()
    # 查询绩效评估记录
    def query_performance_evaluation_record():
        performance_evaluation_id = int(input('请输入要查询的绩效评估记录编号:'))
        cursor.execute('SELECT * FROM performance_evaluations WHERE performance_evaluation_id =?', (performance_evaluation_id,))
        performance_evaluation = cursor.fetchone()
        if performance_evaluation:
            print('绩效评估记录编号:', performance_evaluation[0])
            print('员工编号:', performance_evaluation[1])
            print('绩效评估日期:', performance_evaluation[2])
            print('绩效评估得分:', performance_evaluation[3])
            print('绩效评估等级:', performance_evaluation[4])
        else:
            print('未找到该绩效评估记录!')
    # 绩效评估管理菜单
    while True:
        print('绩效评估管理菜单:')
        print('1. 添加绩效评估记录')
        print('2. 修改绩效评估记录')
        print('3. 删除绩效评估记录')
        print('4. 查询绩效评估记录')
        print('5. 返回主菜单')
        choice = int(input('请选择操作:'))
        if choice == 1:
            add_performance_evaluation_record()
        elif choice == 2:
            modify_performance_evaluation_record()
        elif choice == 3:
            delete_performance_evaluation_record()
        elif choice == 4:
            query_performance_evaluation_record()
        elif choice == 5:
            break
        else:
            print('无效的选择,请重新输入!')
薪资管理功能
def salary_management():
    # 添加薪资记录
    def add_salary_record():
        employee_id = int(input('请输入员工编号:'))
        salary_calculation_date = input('请输入薪资计算日期:')
        basic_salary = float(input('请输入基本工资:'))
        performance_salary = float(input('请输入绩效工资:'))
        bonus = float(input('请输入奖金:'))
        benefits = float(input('请输入福利:'))
        cursor.execute('INSERT INTO salaries (employee_id, salary_calculation_date, basic_salary, performance_salary, bonus, benefits) VALUES (?,?,?,?,?,?)', (employee_id, salary_calculation_date, basic_salary, performance_salary, bonus, benefits))
        conn.commit()
    # 修改薪资记录
    def modify_salary_record():
        salary_id = int(input('请输入要修改的薪资记录编号:'))
        employee_id = int(input('请输入新的员工编号:'))
        salary_calculation_date = input('请输入新的薪资计算日期:')
        basic_salary = float(input('请输入新的基本工资:'))
        performance_salary = float(input('请输入新的绩效工资:'))
        bonus = float(input('请输入新的奖金:'))
        benefits = float(input('请输入新的福利:'))
        cursor.execute('UPDATE salaries SET employee_id =?, salary_calculation_date =?, basic_salary =?, performance_salary =?, bonus =?, benefits =? WHERE salary_id =?', (employee_id, salary_calculation_date, basic_salary, performance_salary, bonus, benefits, salary_id))
        conn.commit()
    # 删除薪资记录
    def delete_salary_record():
        salary_id = int(input('请输入要删除的薪资记录编号:'))
        cursor.execute('DELETE FROM salaries WHERE salary_id =?', (salary_id,))
        conn.commit()
    # 查询薪资记录
    def query_salary_record():
        salary_id = int(input('请输入要查询的薪资记录编号:'))
        cursor.execute('SELECT * FROM salaries WHERE salary_id =?', (salary_id,))
        salary = cursor.fetchone()
        if salary:
            print('薪资记录编号:', salary[0])
            print('员工编号:', salary[1])
            print('薪资计算日期

标签: #数据库 #课程设计 #实例

黑狐家游戏
  • 评论列表

留言评论