One table or two?

L

Leslie Isaacs

Hello All

I have to create a facility within an existing 'Employee' database to manage
employee sickness absence. The data to be input will be the employee's name,
and the start and end dates of any sickness absence periods. These dates,
together with some other 'standing' data held in the existing 'employee'
table, will be used to calculate certain values for each day during the
sickness absence period: essentially, each day during the sickness absence
period will have to be annotated as being of one of 3 'types' (denoted as
"W", "S" or "N"). In addition, each day during the sickness absence period
will be assigned by the user to a 'pay period' (there is an existing table
of 'pay periods'). The rule that determines the 'type' will take account of
the length of the absence period, the proximity of other absence periods for
that employee, and certain other data held about the employee in the
'employee' table. Once calculated it is important that the 'type', and the
'pay period', that are assigned to each day during an absence period are
saved so that their values can be retrieved in the future. They cannot
always be re-calculated because some of the data used in the calculations
may change (primarily the data range of the sickness absence itself) - but
the results of the original calculation must be retained.

The main output needs to be a report showing, for a selected employee and
selected date range, every date between the selected date range, with each
date being displayed either with its 'sickness type' etc. if that date IS
during one of the employees absence periods, or with no 'type' etc. if it is
NOT during one of the employees absence periods. The actual layout of the
report must be to show the absence 'type' (in the case of absence dates), or
a blank field (in the case of other dates) for complete weeks horizontally -
e.g. with field names:

"Sun", "Mon", "Tue", "Wed", Thur", "Fri", "Sat", "Week ending"

the report might look like:

W W S S N N 26/07/08
S S N N N N N 02/8/08
07/8/08
14/08/08
N N N N S S N 21/8/08

The first row above would represent one blank representing 20/08/08, two
"W"s representing 21/08/08 and 22/08, two "S"s representing 23/08/08 and
24/08/08 and two "N"s representing 25/08/08 and 26/08/08. The third and
forth rows represent week with 7 'blanks' - i.e. these weeks contain no
dates that fall within any sickness absence period for the employee.
The assigned 'pay period' would not be included on this report.

My initial plan was to have a table 'sickness_periods', containing just the
employee name and the start and end dates of each sickness period, plus a
table 'sickness_days', containing the results of the calculations. Now I am
wondering whether I shouldn't bother with the first 'sickness_periods'
table, and instead just enter the data range into two unbound fields on the
data entry form, do the calculations and then save the results to the
'sickness_days' table.

In writing the above I can see that my question may have become too long to
get responses from this forum! Obviously I don't expect anyone to give me
all the answers - I'm just looking for some advice about which way to go
with this, as I think I'm in danger of getting it horribly wrong! Any
general pointers would be very much appreciated.

Many thanks
Leslie Isaacs
 
M

Michael Gramelspacher

Hello All

I have to create a facility within an existing 'Employee' database to manage
employee sickness absence. The data to be input will be the employee's name,
and the start and end dates of any sickness absence periods. These dates,
together with some other 'standing' data held in the existing 'employee'
table, will be used to calculate certain values for each day during the
sickness absence period: essentially, each day during the sickness absence
period will have to be annotated as being of one of 3 'types' (denoted as
"W", "S" or "N"). In addition, each day during the sickness absence period
will be assigned by the user to a 'pay period' (there is an existing table
of 'pay periods'). The rule that determines the 'type' will take account of
the length of the absence period, the proximity of other absence periods for
that employee, and certain other data held about the employee in the
'employee' table. Once calculated it is important that the 'type', and the
'pay period', that are assigned to each day during an absence period are
saved so that their values can be retrieved in the future. They cannot
always be re-calculated because some of the data used in the calculations
may change (primarily the data range of the sickness absence itself) - but
the results of the original calculation must be retained.

The main output needs to be a report showing, for a selected employee and
selected date range, every date between the selected date range, with each
date being displayed either with its 'sickness type' etc. if that date IS
during one of the employees absence periods, or with no 'type' etc. if it is
NOT during one of the employees absence periods. The actual layout of the
report must be to show the absence 'type' (in the case of absence dates), or
a blank field (in the case of other dates) for complete weeks horizontally -
e.g. with field names:

"Sun", "Mon", "Tue", "Wed", Thur", "Fri", "Sat", "Week ending"

the report might look like:

W W S S N N 26/07/08
S S N N N N N 02/8/08
07/8/08
14/08/08
N N N N S S N 21/8/08

The first row above would represent one blank representing 20/08/08, two
"W"s representing 21/08/08 and 22/08, two "S"s representing 23/08/08 and
24/08/08 and two "N"s representing 25/08/08 and 26/08/08. The third and
forth rows represent week with 7 'blanks' - i.e. these weeks contain no
dates that fall within any sickness absence period for the employee.
The assigned 'pay period' would not be included on this report.

My initial plan was to have a table 'sickness_periods', containing just the
employee name and the start and end dates of each sickness period, plus a
table 'sickness_days', containing the results of the calculations. Now I am
wondering whether I shouldn't bother with the first 'sickness_periods'
table, and instead just enter the data range into two unbound fields on the
data entry form, do the calculations and then save the results to the
'sickness_days' table.

In writing the above I can see that my question may have become too long to
get responses from this forum! Obviously I don't expect anyone to give me
all the answers - I'm just looking for some advice about which way to go
with this, as I think I'm in danger of getting it horribly wrong! Any
general pointers would be very much appreciated.

Many thanks
Leslie Isaacs
I think you need a table like this:

CREATE TABLE Absenses (
employee_id INTEGER NOT NULL
REFERENCES Employees (employee_id),
absence_date DATETIME NOT NULL,
absence_type CHAR(1) NOT NULL,
CHECK (absence_type IN ("W","S","N")),
PRIMARY KEY (employee_id, absence_date));

Then using a calendar table you may be able to come up with a crosstab query
that does what you want.

I am only a hobbiest and only answered because I do not see any other responses.
 
K

Klatuu

If your requirements are to report on each day for the occurance, then you
need a record for each day. To tie the records together in to one occurance,
you could use a field that defines the occurance.
 
M

Michael Gramelspacher

I think you need a table like this:

CREATE TABLE Absenses (
employee_id INTEGER NOT NULL
REFERENCES Employees (employee_id),
absence_date DATETIME NOT NULL,
absence_type CHAR(1) NOT NULL,
CHECK (absence_type IN ("W","S","N")),
PRIMARY KEY (employee_id, absence_date));

Then using a calendar table you may be able to come up with a crosstab query
that does what you want.

Based on the what I wrote above, this is the best result I can come up with
using a crosstab query.

EmployeeId First Last Sun Mon Tue Wed Thu Fri Sat
1 7/27/2008 8/2/2008 N N S S N N N
2 7/27/2008 8/2/2008 N N N N N N N
 
L

Leslie Isaacs

Hello Steve

Many thanks for your suggestion.

By "analogue calendar" do you mean one that actually looks like a calendar -
like the calendar control? If so, creating a form that looks like that
sounds like a great idea ... but I can't think how to create such a thing!

Any help would certainly be appreciated.

Thaks again
Les
 
J

John... Visio MVP

Careful Leslie, Steve is a known troll in these newsgroups. His sole purpose
is to get users to ask him to do work. Microsoft provides these newsgroups
for FREE peer to peer support. This is one of steve's tactics to get around
that issue. There are many here who will help you for no more than a thank
you.

He has been trolling these newsgroups for years and the fact that he has to
continue to do it indicates that he does not get much repeat business, which
speaks to the quality of his work.

John... Visio MVP
 
J

John... Visio MVP

Leslie Isaacs said:
Hello Steve

Many thanks for your suggestion.

By "analogue calendar" do you mean one that actually looks like a
calendar - like the calendar control? If so, creating a form that looks
like that sounds like a great idea ... but I can't think how to create
such a thing!

Any help would certainly be appreciated.

Thaks again
Les


Tony Toews, one of the Access MVPs who loves to help out has a webpage on
the subject.
http://www.granite.ab.ca/access/calendars.htm

John... Visio MVP
 
J

John... Visio MVP

Steve said:
I could implement the calendar for you for a very reasonable fee.

Steve

True to form and as predicted, you have crawled out from under your rock and
are pestering the newsgroup users for work.

These newsgroups are provided by Microsoft for FREE peer to peer support,
not as a venue for you to offer your questionable services.

Roberta must be really impressed with your sleazy business practices.

John... Visio MVP
 
J

John... Visio MVP

John... Visio MVP said:
Tony Toews, one of the Access MVPs who loves to help out has a webpage on
the subject.
http://www.granite.ab.ca/access/calendars.htm

John... Visio MVP

There is also http://www.datastrat.com/Download/Calendar2K.zip from Arvin
Meyer, another Access MVP who also does not charge for helping.

And from another Access MVP, A.D. Tejpal, he has two downloads at
http://www.rogersaccesslibrary.com/OtherLibraries.asp#Tejpal,A.D.
(a) Crosstab_CalendarStyleTaskPlanner
(b) Query_CrosstabAttendanceMarking
that may be helpful.

As I have said many times in the past, there are many highly qualified
people who respect the free nature of these newsgroups and are more than
willing to help. Steve is not one of them.

John... Visio MVP
 
L

Leslie Isaacs

Hello Jon

Many thanks for your suggestions and references: I will certainly check them
all out, although it's going to have to wait until next week now, as I have
a few other things I need to attend to.

I also appreciate your 'warning me off' using anyone seeking to gain
business through the newsgroup. That said, I will just mention that on a few
occasions in the past I have received similar offers from well-respected
newsgroup contributors. This has been at the point where the help required
has gone beyond that which could reasonably be expected for free. Many times
I have been amazed just how much help I have received - for free, with the
effect that the dividing line between free work and chargeable work is
uncertain and variable. On one occasion, at the end of a long (and
successful) thread with a highly respected contributor, he pointed out that
the help given had gone well beyond the normal free level and therefore if I
felt like paying for it that was all right with him!! I was very surprised
at the time - not because the help hadn't been valuable to me, but because I
simply hadn't seen it coming.

I seem to recall that the rules of the newsgroup dictate that a contributor
should not explicitly offer their chargeable services, and this is obviously
what Steve did. No real harm done though, and if I am unable to implement
any of the tips/tools at the references you have given (through my lack of
expertise!) I am not sure I can see a reason not to pay someone - like
Steve - to provide the facility that I need. Then it would obviously be a
matter of my specifying exactly what I expected for my money, and how much
I'd be paying. With a bit of luck though, I'll be able to work it out for
myself - with help from your references!

I'll let you know how I get on, next week.

Thanks again for all your help.
Les
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top