Yes I agree that the coding for the "time range" idea could get very ugly very quickly.
Especially when someone needs access from 800AM to 1000AM then from 200PM to 300PM then from 8PM to 1200PM etc.
It could get pretty hard to make that user friendly!!!
I think I am going to go with the time slot method. For several reasons.
1) there more than likely will be multiple people maintaining this application.
2) It should be easier to develop a GUI for the time slot method.
Also I have a little advantage in that there will "never" (I hate to use that word in database design however I think it is warranted here.) be more than 96 time slots per day for each zone.
No one here can imagine more than 48 time slots per day for each zone so if I design it for 96 it should be well within the spec. I know this ties the application to 96 time slots but I think that is OK because I also need to provide a GUI for this thing and I don't want to make the GUI so complicated it can't be used.
so what I am thinking is very close to your recommendation.
tblZone - 1 row per zone.
ZoneID (pk)
name, description, whatever
tblDayNames - 1 row per generic day-of-week.
DayID (pk)
name (e.g. "Tuesday")
tblTimeslot - 1 row per timeslot.
TimeslotID (pk)
start time
end time
tblEmployee
EmpID (pk)
name, date of birth etc.
tblAccess
ZoneAccessID (pk)
ZoneID
DayID
EmpID
TimeSlot1Access (yes/no)
TimeSlot2Access (yes/no)
TimeSlot3Access (yes/no)
|
|
\ | /
\|/
TimeSlot94Access (yes/no)
TimeSlot95Access (yes/no)
TimeSlot96Access (yes/no)
Thanks for your help on this
Also feel free to comment on what I described above.
-Merk
Ok. This will need careful handling to ensure that you get reasonable data
storage (not 50 gazillion records per person), AND, a workable user
interface.
Let's start by designing the tables on the asumption that >everything< will
be stored in a table. Then we'll see what that gives us, & whether it will
be workable. This is what you'd get, with that approach. (Note: the names of
the non-key fields in each table are just descriptive. You would want to
choose names that are not Access reserved words.)
tblZone - 1 row per zone.
ZoneID (pk)
name, description, whatever
tblDayNames - 1 row per generic day-of-week.
DayID (pk)
name (eg. "Tuesday")
tblTimeslot - 1 row per timeslot.
TimeslotID (pk)
start time
end time
tblEmployee
EmpID (pk)
name, date of birth etc.
Now we need a table defining which employees can access which timeslots on
which days in which zones:
tblAccess
ZoneID ( com-
DayID posite
TimeslotID primary
EmpID key )
If you found that 4-field composite key unweildy, you could change it to a
unique index, & add an autonumber as the primary key.)
The presence of a record in that table, shows that the specified employee
does have access to that timeslot, on that day, in that zone. The absence of
a particular record, shows he does not have that access.
As you rightly pointed out, this will be a lot of records! (You said
2,318,400 for 100 employees). However, 2+ million records is well within
Access'es capabilitiues (as long as everything is PK-d properly), >and<,
your calculation assumed that each employee has a record for each timeslot
in each day in each zone. If you only stored the "yes, he has access!"
records - as shown above - this would cut that figure down quite a bit.
On reflection, I really can't see any way to cut the records down much
further. Certainly you could eliminate the tblDayNames and tblTimeslots
tables - and I would probably do that - but this saves you a negiligble # of
rows in the scheme of things. You still have the same # of rows in
tblAccess.
The only other way I can see, is to store time >ranges<, and cauclate time
slots< at runtime. So if an employee had access to timeslots 1 (8:00-8:15
or whatever), 2 (8:16-8:30), 3 (8:31-8:45) and 4 (8:46-9:00), perhaps you
could store just 1 record for that employee, showing that he had access from
start-time 8:00 to end-time 9:00? Then for forms & reports could convert
those ranges back to timeslot #s, at runtime, for display/reporting
purposes. If the employee had disjoint time ranges (say 8:00-9:00 and
10:00-10:30), he would just have several 'time range" records for the day
and zone in question.
Personally I would be tempted to prototype the "time range" idea. But you
would need to keep a careful eye out, for unwanted coding complexity. The
advantage of the time slot method is that the coding would be very simple.
HTH,
TC
Merkling said:
- Any employee (say Fred Smith) can select any one of the 32 zones (without
restriction).
----- Only Fred Smith (the boss) or an administrator would be able to
grant or restrict access to any one of the 32 Zones for any employee.
- Then (for the selected zone), he can select any one of the 7 days of the
week (without restriction).
----- Yes
- Then (for the selected day), he can select any one of the 96 time slots
(without restriction).
----- Yes
- Then (for the selected time slot), he can say "ALLOW access!", or "DENY
access!", by ticking a checkbox, or whatever.
----- Yes by ticking a checkbox
Questions:
- Does Fred need to nominate who or what he is allowing or denying access
----- Fred Smith would do this for each employee he wanted to grant access
to a Zone(for a certain time slot). If he did not specifically grant access
for a particular employee to a particular zone for a particular time slot
they would not be granted access for that time slot.