mysql - 高效考勤管理系统的数据库架构

标签 mysql database database-design architecture schema

我正在为学校开发一个考勤系统,该系统将同时满足员工和学生的需求。

当前的数据库模式是

考勤

id - primary key for this table
daydate  int(11) - stores timestamp of current day
timing_in varchar(18) - Start time for institution
timing_out - Closing time for institution
status - Status for the day, can be working day - 1 or holiday - 2

然后有不同的表供教职工和学生存储实际出勤值。

对于员工,出勤存储在 attendance_staff 中。数据库模式是

attendance_id - foreign key, references attendance table
staff_id - id of staff member, references staff master table
time_in - stores in timing of a staff member
time_out - stores out timing of a staff member
status - attendance status - can be one among the list, like present, absent, casual leave, half day, late mark, on duty, maternity leave, medical leave etc

对于员工,我在表中存储了在场和不在场的条目。

现在必须包括学生的出勤率。

由于每天的状态已经存储在 attendance 表中,我们是否可以在学生出勤表中存储每个学生的当前值。

例如,学生出勤表将仅存储特定日期不在场的那些天的条目。

attendance_student 的架构将是

attendance_id - references attendance table
student_id - references student table
status - will be leave / absent etc other than present.

用outer join从出勤表中计算出现在的天数效率高吗??

提前致谢。

最佳答案

您不需要外部联接来计算学生的出勤率。您可以简单地计算出勤表中的记录(一次,因为它对所有学生都是一样的),然后从学生出勤表中选择以获得缺勤。

如果您更愿意使用外部联接来计算出勤率,您可以这样做。如果您在出勤表主键和从学生出勤表到出勤表的外键上有一个索引,那么效率可能会更高。

关于mysql - 高效考勤管理系统的数据库架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14098346/

相关文章:

mysql - MySQL 查询中跳过天数的逻辑

php - 在 mysql php 中选择不同的值

php - 如何使用 PHP 从 url 访问 mysql 表中的字段

sql-server - 用于存储网页的数据库字段类型

mysql - 二进制与整数 - 作为主键?

mysql - 需要一个MYSQL查询来比较两个表并且只输出不匹配的结果

python - torndb(MySQLdb) 查询参数不起作用

php - 如何从mysql数据库获取一个用户的等级?

php - 未使用函数 password_verify 验证密码

mysql - 创建一个包含 now() 纪元的整数默认字段值