简体   繁体   中英

Mysql data retrieval

I am creating a attendance management system for my company. For that I have a table in my mysql database called PRESENCE. The table looks like below.

+------+-------------+---------+----------+-----------+--------+------+------+

| pid | shift_time | timein | timeout | workhours | date | uid | day |

+------+-------------+---------+----------+-----------+--------+------+------+

I have two buttons in my html for check in and check out. Employees login daily and click the check in button when they come to office. When they click the check in button i insert a new row to the above table with

pid(auto incremented),
timein(server time),
timeout(default value 00:00:00),
date(server date),
uid(logged in employee id),
day(present day like monday,tuesday etc.)

And when they click the check out button i just update the timeout value to server time and calculate workhours and update that too.

In my html i have written a select query to select all rows for a particular employee id from this table and show the output. Now my problem is that if a user is not checking in for any date i want that date to be shown as "absent" or "no-shift". I am not really sure how to do this. Any ideas and help would be greatly appreciated. I need to finish this project as soon as possible.

Thanks in advance.

If you make an assumption that a worker is expected to work five week days, then for the 'absent' or 'no-shift' case you could show the days there is no shift entry. These missing rows would need to be explained by the worker.

At a minimum i think you need to add a 'type' column to the table which would be an enum of (SHIFT,ABSENT).

In general you single table schema seems a bit restrictive for these extra use cases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM