What is a good database design (schema) for a attendance database?(考勤数据库的良好数据库设计(架构)是什么?)
问题描述
我正在尝试申请一个亲戚的武术工作室的出勤率.我试过四处寻找一些类似的例子,但我找不到适合这种应用程序的任何具体或足够清晰的例子.
I'm trying to make a application for keeping attendance for a relative's martial arts studio. I've tried looking around for some similar examples, but I couldn't find any specific or clear enough ones for this kind of application.
目前,我使用了两个表,一个用于保存学生信息,students(id, first_name, last_name, email, ...),另一个表用于按一年中的周数出勤,出席(id,周_1、周_2、周_3、...).我试图改变它以保持几天的出勤率,但似乎想不出一个好的方法,因为我对 MySQL 还是有点陌生.
At the moment, I am using two tables, one for keeping student information, students(id, first_name, last_name, email, ...), and another table for attendance by the weeks in a year, attendance(id, week_1, week_2, week_3, ...). I am trying to change it to keep attendance by days instead, but can't seem to think of a good approach since I'm still kind of new to MySQL.
我正在努力使其能够以类似日历的格式查看出席情况.只制作 365 天的列可能会很糟糕……每个月都有一张表格也是如此.我注意到一些类似的应用程序只是跟踪日期,并将其存储在数据库中.这种方法会更好吗?或者,是否有其他更好的方法来设计这种数据库?提前致谢.
I am trying to make it so it is possible to see the attendance in a calendar-like format. It probably would be bad to just make columns for 365 days... and same with having a table for each month. I've noticed some similar applications just keep track of the dates, and store that in the database. Would this approach be better? Or, is there some other better approach to designing this kind of database? Thanks in advance.
推荐答案
出勤应该有 id、student_id 和 date.这是您在学生参加时需要记录的全部内容.如果您想知道在特定日期有多少学生(以及谁)就读,您可以针对该特定日期或日期范围运行查询.
Attendance should have id, student_id and date. This is all you need to record when students attended. if you want to know how many students attended on a specific date (and who) you run a query for that specific date or date range.
您还可以创建一个课程表,在这种情况下,出勤表将是id、student_id 和 course_id课桌可以是id,hold_on_date
You could also create a lesson table, in which case the attendance table would be id, student_id and lesson_id the lesson table could be id, held_on_date
除非您需要在课程表中添加更多列,否则我认为这是矫枉过正.
unless you need to add more columns to the lesson table, I think it is overkill.
这篇关于考勤数据库的良好数据库设计(架构)是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:考勤数据库的良好数据库设计(架构)是什么?
基础教程推荐
- Sql Server 字符串到日期的转换 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01