I am designing a very small relational database for tracking my salaries from different jobs. Since I work several jobs and one job the work schedule is almost fixed, being every workday from 9am to 2:30pm and it’s a long term position and I get paid on a monthly basis. The other jobs the schedule is uncertain and quite random, and I get paid by hours.
Here is my dilemma. If I record every hour that I work for all those jobs and the corresponding wage that I get from it, in a single table, then I will have to divide my monthly wage from that fixed schedule job by all the working hours in one month, and it will also mean that there will be a lot of repeating input for that fixed schedule job(e.g. 9am to 10am; 10am to 11am; etc.) with exactly the same values. On the other hand, if I make the payment interval weekly or monthly, it will definitely fit my fixed schedule job but will lose a lot of information that I should keep track of for those non-repeating cycle working hours. I could make two different tables but two different tables will basically record the same class just with differently time intervals, does it sound wise? To add things a little more complicated, I do want to keep track of leaves for my fixed schedule job so tracking it by days instead of months is actually desirable.
Any suggestion here would be highly appreciated. Thanks.
I guess you have two options here:
as you proposed, have two tables, one that captures the adhoc payments and one table that stores the regular (weekly/monthly) payments.
Advantage here is that nicely split the two types incomes. The disadvantage is that your reporting gets a bit more complicated to program. You always need to add the two tables based on some logic how to distribute the regular payments.
you keep onlyone single table but you distribute the regular payments upon entry across the various days, e.g. if you get $200 for 4 weeks, you’ld create an entry per working day (Assuming 5 days a week) of 10$.
I personally would go for option 2:
Create a master table for the regular payments that defines the interval (weekly/monthly,quarterly,etc.) as well as the hours that this payment is for, e.g. 20 hours per month at $100.
Create one table to capture the actual details, that could then look something like this:
Date/FromTime/NumberOfHours/Type/AmountEarned/RegularIncomeID
Type would then define whether it is a regular or an adhoc payment (allows for some sort of reporting details) and RegularIncomeID would be a link to your master table.
For the regular earned time, I’ld either leave the FromTime empty (probably not good if you plan to keep that field as part of a unique index as some DB systems dont allow NULL values in unique/primary indexes) or enter a default value such as 0AM.
Option two has the advantage this it makes all your reporting much easier, such as show me hours worked per day for the last 3 months. Try doing this with option 1, probably possible too, but you’ld need to add a lot of programming logic, whereas options 2 would be a simple SQL statement.