Dear StackOverflowers,
Waves' original question on the best design for a punch in/out table was posted as a result of a brief discussion I had with him at work. We work together in the IT department at our company, and I'm the one working on a replacement for the current paper time card process. So I thought I'd throw in my oar here when waves told me that he'd posted a question on my behalf.
Currently we have a mechanical punch clock for non-exempt hourly employees that work in the plant. Non-exempt hourly OFFICE employees (the ones that wear clean shirts) fill out time sheets by hand rather than punch the clock.
My boss wants me to write a system that makes use of a proximity reader for the plant workers. This system will also allow plant as well as office workers to punch in/out using their company login IDs on a PC.
We use proximity readers at all the entrances to the building and entry/exit times are recorded in SQL Server tables using proprietary software. I have access to the SQL Server tables and have already written a companion web page that shows an In/Out Board at the receptionist's desk.
The readers at the entrances come in pairs: one on the outside of the building at each entrance and a corresponding one on the inside of each entrance. Thus the readers record whether an employee is entering or exiting the building based on the physical location of the reader.
I'm supposed to use one of those "dumb" readers as the reader for the time card replacement program. Therefore it does not know if a punch is an "in" or an "out" punch.
I've speculated that we could use two readers for punches by plant personnel in a similar fashion to using the current entry/exit readers; that is, when punching in, swipe this reader, and when punching out swipe that reader. But because of the requirement to allow any non-exempt employee to punch in/out at a PC, I've been kind of stumped as to how I'd handle the In/Out designation for office workers to match the dual readers for the plant people.
So here's what I've come up with so far:
- A "raw" punch table containing EmployeeNumber, TimeStamp, and PunchDevice -- whether a proximity reader or a PC. This table would include any punches, even those made by an employee who swipes the reader three or four times in succession within a couple seconds.
- An In/Out table containing EmployeeNumber, InTimeStamp, and OutTimeStamp.
- A Personnel table that contains a single record for each employee. That record also contains fields for LastTimestamp, the "raw" punch record key, and the key for the In/Out table record.
If the In/Out key field in the Personnel table is empty/NULL, then a new record has to be inserted into the In/Out table and the InTimeStamp is filled with the TimeStamp from the "raw" table. The Personnel table's In/Out key field is then updated with the key from the newly created In/Out record.
If the In/Out key field in the Personnel table contains a key value, then the corresponding record in the In/Out table is located and updated with the latest TimeStamp from the "raw" table in the OutTimeStamp field. The In/Out key field value is then removed from the Personnel table.
It's a pretty problem, all right. Now, before you ask why we don't just use the information from the Entry/Exit system I'll tell you that because of the policies in the Human Resources dept. here, we allow people to enter the building well ahead of their shifts. BUT the employee may not punch in more than 7 minutes before the start of his shift. So the employees have been "conditioned" already to hang out at the punch clock until 7 minutes before the start of their shift; then they punch in in rapid succession.
We do this because if the employee punches in 8 minutes before the start of his shift, the company has to pay him for an extra quarter-hour. Similarly if an employee punches out at the end of his shift 8 minutes after its end, the company has to pay him for an extra quarter-hour.
I apologize for the length of this, but I felt it was important to the excellent answers that have been given here to have a fuller explanation of the context. Again, waves posted a question on my behalf and I'm essentially "hijacking" the thread. I hope his is OK.
Sincerely,
Steve Erbach
Neenah, WI
P.S., I'd like to give credit to those with helpful answers. May I do that as a "thread hijacker"?