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

时间:2012-12-31 06:37:08

标签: mysql database database-design architecture schema

我正在为学校开设一个考勤系统,以满足员工和学生的需求。

当前的数据库架构是

attendance

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.

使用外部联接来计算出勤日期的当前天数是否有效?

提前致谢。

1 个答案:

答案 0 :(得分:2)

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

如果您更愿意计算外部联接的出勤率。如果您的考勤表主键和从学生出勤表到出勤表的外键上有索引,那么这可能会非常有效。