I
I
illuminance2020-12-20 16:33:23
MySQL
illuminance, 2020-12-20 16:33:23

Staff work schedule, how to write to the database (mysql)? what structure to create?

I have a staff schedule according to which wages will be calculated, the number of working days and days off for each employee, it doesn’t occur to me how to write to the database, that is, what columns to create? whether it will be days (1-31)? the schedule will also change depending on which month.

The question is how can I build a structure in the database so that I can write to the database from the inputs!?

An example of a chart that needs to be implemented in the admin panel. that is, everything is as in the example, only how should the structure in the database look like?
5fdf5229907bc775879709.png
So I made a table for 31 calendar days, each cell has an input
5fdf5368c87f7241019708.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kisaa, 2020-12-20
@kisaa

Table Employees:
Id, Full Name, Department, Position, ...
Table TypeDay:
Id, TypeDay (working, day off, sick leave, vacation, study, ...)
Table Timesheet:
Id_employee, Date, Id_DayType
Connection of the first two with the third through keys

F
Flying, 2020-12-20
@Flying

kisaa 's answer gives a first approximation of what a database structure might look like.
However, most likely it is also necessary to take into account the fact that the day "in fact" will probably differ from the day "according to the plan". For example, someone took a day off at their own expense or suddenly fell ill. Therefore, most likely, there should be two schedules - planned and real, while the data from the "planned" will have to be copied every day to the "real" with subsequent adjustments.
Also, if all this is also taken into account when calculating wages, you need to take into account a number of other parameters:

  1. Actual hours worked, if it affects payroll
  2. Recycling, possibly with an indication of paid / no and a multiplier
  3. Good/Illegal Cause (Deducted from salary or not)

This, of course, is only offhand, there may probably be other factors, but the information in the question is not enough to answer.
Also, I think it is very important to find out why, in principle, such a decision is made, and not ready-made solutions based on 1C are used? There are still so many nuances and scenarios that there is an almost 100% chance to spend a lot of time, fill a lot of bumps and give rise to very unpleasant situations due to payroll errors, especially without having experience in this area.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question