What a massive worm of worms that you open here, mat. After working for a company that deals only with synchronization systems, I will never want to do it again!
I understand that my answer is very conceptual and touches on several questions outside the normal scale of the question, but this is in order to present the database design and structural concepts in this type of application. This information comes from the recent development of a specialist that I did in this area, so it is not only hypothetical, but also proven in practice.
When you look at this type of system, it is best to use indicators as flags, this is usually the number of strokes compared to each record. To compare each entry for 1000 employees, this is not the best thing!
For example, if a user has 8 strokes within 24 hours (start of day, morning break, morning break, lunch, lunch, start of day break, day break and end of day), you may be unlikely to have missed strokes during this period, and overtime took place, however, if within 24 hours there were 7 strokes (beginning of the day, beginning of the morning break, morning break, beginning of lunch, lunch, day break beginning and end of the day), you know that there is no breakdown, and the person forgot stand for a day. Please note that there is no day to end.
However, this is not a complete proof and provides only an indicative link; you will need to compare the switching schedule with the punches to make sure that nothing was missed. Because it is possible that both sides of the lunch and lunch break were skipped, leaving 6 strokes, you can set your code to mark everything that is not the X-number of strokes for this employee. When you are tagged, you then do the actual comparison of that employee over this period to find out what actually happened and what was missed.
This does not mean that you are not comparing all the records, but, nevertheless, depending on the number of employees, this can cause some big problems, making an exact comparison for each record, exactly where it is usually better to use 2 servers for more employees , 1 to collect data and only an interface, the second to perform comparison processes.
As I said, for this type of application and for working with different schedules, you also need to look at the shift shift graphs for comparison. You will want to make a record for each employee, which will give equal time before the start of the shift and after the end of the shift. This will mean that the likelihood of overtime exceeding 1 period of time will be minimal. The basic form is very simple: the number of hours per shift - 24 hours / 2 = laying time
Now you put the time filling before and after the switching schedule for this user. But you still need to handle a shift shift, change, or more than a 24-hour shift. Everything becomes complicated here. You will want to look at a table of overlapping times (indentation, shift, and strokes), which can then be consistent with any future schedule adjustments, because after changes in facts are not uncommon when visiting time.
Now you also want to create a table of absentee periods for sick leave and leave, this data should then be marked as a rule in the punch-in / punch-out table, as this is what you are comparing with. When the flag is set for a certain period, the record can be skipped in comparison, and the note remains in the report without the need to start additional operations to check it.
Almost at the end, pay attention to how you need to forget about your normal time and time conventions to measure this for a number of variables? Not to mention working efficiently and effectively for several dates? Because of this, you are usually better off working only with start and end times with dd / mm / YYYY hh: mm: ss, UNIX time is used for measurements to calculate how much time has passed. Saying that for auditing, most systems need a “date stamp” record, so processing the server side of this may be necessary when issuing reports.
Finally, I would also recommend conducting a results table, this will give reporting results for each user, so when you want to provide historical records that you can dynamically generate documents, however, you do not need to waste computational power when comparing is recorded every time it is requested report.
Hope this helps!