我正在为学校开发一个考勤系统,该系统将同时满足员工和学生的需求。
当前的数据库模式是
考勤
表
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/